Skip to content

Commit

Permalink
fix: bytearray compile-error about func
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed Jun 14, 2024
1 parent af1c615 commit 704c95d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/pylib/pybytearray.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ template asNim(self: PyByteArray): string =
converter toPyBytes*(self): PyBytes = bytes self.data
# then all non-inplace method are dispatched to PyBytes

func `*=`*(mself; n: int) =
## 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

template wrapCmp(op){.dirty.} =
Expand Down Expand Up @@ -143,6 +132,16 @@ func delitem*(mself; i: int) =

func clear*(mself) = mself.asNim.setLen 0

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

func getCharRef(mself; i: int): var char = mself.asNim[i]

func reverse*(mself) =
Expand Down

0 comments on commit 704c95d

Please sign in to comment.