[pypy-commit] pypy py3.5: small fix to hex()

arigo pypy.commits at gmail.com
Sat Aug 27 04:09:28 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r86593:9fc4d6946a5b
Date: 2016-08-27 10:08 +0200
http://bitbucket.org/pypy/pypy/changeset/9fc4d6946a5b/

Log:	small fix to hex()

diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -1,5 +1,6 @@
 """The builtin bytearray implementation"""
 
+import sys
 from rpython.rlib.objectmodel import (
     import_from_mixin, newlist_hint, resizelist_hint, specialize)
 from rpython.rlib.buffer import Buffer
@@ -496,7 +497,6 @@
     return data
 
 HEXDIGITS = "0123456789abcdef"
-PY_SIZE_T_MAX = intmask(2**(rffi.sizeof(rffi.SIZE_T)*8)-1)
 
 @specialize.arg(3) # raw access
 def _array_to_hexstring(space, buf, len=0, rawaccess=False):
@@ -504,11 +504,11 @@
         length = len
     else:
         length = buf.getlength()
-    hexstring = StringBuilder(length*2)
 
-    if length > PY_SIZE_T_MAX/2:
+    if length > sys.maxint / 2:
         raise OperationError(space.w_MemoryError, space.w_None)
 
+    hexstring = StringBuilder(length*2)
     for i in range(length):
         if rawaccess:
             byte = ord(buf[i])


More information about the pypy-commit mailing list