[pypy-issue] Issue #2924: int.to_bytes argument name "nbytes" should be "length" (pypy/pypy)
Daniel Herding
issues-reply at bitbucket.org
Mon Dec 3 10:16:33 EST 2018
New issue 2924: int.to_bytes argument name "nbytes" should be "length"
https://bitbucket.org/pypy/pypy/issues/2924/intto_bytes-argument-name-nbytes-should-be
Daniel Herding:
Our codebase contains code like this:
int.to_bytes(1024, length=8, byteorder="big")
Running the same code in Python 3.5.3 [PyPy 6.0.0 with GCC 6.2.0 20160901] on linux leads to:
TypeError: to_bytes() got an unexpected keyword argument 'length'
Running int.to_bytes() in PyPy shows:
TypeError: to_bytes() missing 3 required positional arguments: 'self', 'nbytes', and 'byteorder'
The following works in PyPy:
int.to_bytes(1024, nbytes=8, byteorder="big") # Does not work in CPython
or simply
int.to_bytes(1024, 8, byteorder="big") # Also works in CPython
Omitting the name of the positional argument is a possible workaround, which has been used by other people:
https://github.com/LonamiWebs/Telethon/issues/833
However, it would be nice if PyPy accepted the standardized argument name "length" instead of "nbytes".
More information about the pypy-issue
mailing list