Skip to content

Commit

Permalink
python: return None instead of bytearray() for zero length variable b…
Browse files Browse the repository at this point in the history
…yte buffers
  • Loading branch information
jgriffiths committed Jul 22, 2022
1 parent 4a67bc5 commit df3e69a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/swig_python/python_extra.py_in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def _wrap_bin(fn, length, resize=False):
""" Wrap functions that take an output buffer to create/return it """
def wrapped(*args):
n = length(*args) if callable(length) else length
if not n:
return None
buf = bytearray(n)
ret = fn(*list(args)+[buf])
if resize:
Expand Down

0 comments on commit df3e69a

Please sign in to comment.