Skip to content

Commit

Permalink
fix padding
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Feb 20, 2025
1 parent 9fca298 commit 4f38a7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vyper/builtins/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ def to_bytes_m(expr, arg, out_typ):
if isinstance(expr, vy_ast.Constant) and arg.typ.length <= out_typ.m:
val = expr.value
if isinstance(arg.typ, StringT):
val = expr.value.encode("utf-8")
arg = int(val.hex(), 16)
val = val.encode("utf-8")

# bytes_m types are left padded with zeros
arg = int(val.hex(), 16) << 8 * (out_typ.m - arg.typ.length)

elif isinstance(arg.typ, BytesT):
bytes_val = LOAD(bytes_data_ptr(arg))
Expand Down

0 comments on commit 4f38a7f

Please sign in to comment.