[pypy-commit] pypy py3.5: use cpython's argument name (should maybe be done more systematically?)

cfbolz pypy.commits at gmail.com
Mon Dec 3 12:02:35 EST 2018


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: py3.5
Changeset: r95406:ce637db93b36
Date: 2018-12-03 17:42 +0100
http://bitbucket.org/pypy/pypy/changeset/ce637db93b36/

Log:	use cpython's argument name (should maybe be done more
	systematically?)

diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -97,8 +97,8 @@
             w_obj = space.call_function(w_inttype, w_obj)
         return w_obj
 
-    @unwrap_spec(nbytes=int, byteorder='text', signed=bool)
-    def descr_to_bytes(self, space, nbytes, byteorder, signed=False):
+    @unwrap_spec(length=int, byteorder='text', signed=bool)
+    def descr_to_bytes(self, space, length, byteorder, signed=False):
         """to_bytes(...)
         int.to_bytes(length, byteorder, *, signed=False) -> bytes
 
@@ -121,7 +121,7 @@
         """
         bigint = space.bigint_w(self)
         try:
-            byte_string = bigint.tobytes(nbytes, byteorder=byteorder,
+            byte_string = bigint.tobytes(length, byteorder=byteorder,
                                          signed=signed)
         except InvalidEndiannessError:
             raise oefmt(space.w_ValueError,
diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -378,6 +378,7 @@
         assert (-8388608).to_bytes(3, 'little', signed=True) == b'\x00\x00\x80'
         raises(OverflowError, (-5).to_bytes, 1, 'big')
         raises(ValueError, (-5).to_bytes, 1, 'foo')
+        assert 65535 .to_bytes(length=2, byteorder='big') == b'\xff\xff'
 
     def test_negative_zero(self):
         x = eval("-self._long(0)")


More information about the pypy-commit mailing list