Skip to content

Commit

Permalink
fix(py): bytearray *= as Python does
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed Jun 14, 2024
1 parent 6b46fca commit af1c615
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pylib/pybytearray.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ converter toPyBytes*(self): PyBytes = bytes self.data
# then all non-inplace method are dispatched to PyBytes

func `*=`*(mself; n: int) =
mself.data = mself.data.repeat n
## bytearray.__imul__
##
## Python: if n < 1: self.clear()
if n < 1:
mself.data.setLen 0
return
if n == 1: return
mself.data.add mself.data.repeat n-1


# End impl
Expand Down

0 comments on commit af1c615

Please sign in to comment.