[pypy-commit] pypy py3k: Remove 'L' suffix from the output of hex() and oct()
amauryfa
noreply at buildbot.pypy.org
Sat Jan 14 21:48:36 CET 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r51326:83fc38544bca
Date: 2011-12-26 23:48 +0100
http://bitbucket.org/pypy/pypy/changeset/83fc38544bca/
Log: Remove 'L' suffix from the output of hex() and oct()
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
@@ -211,8 +211,8 @@
def test_format(self):
assert repr(12345678901234567890) == '12345678901234567890'
assert str(12345678901234567890) == '12345678901234567890'
- assert hex(0x1234567890ABCDEFL) == '0x1234567890abcdefL'
- assert oct(01234567012345670L) == '01234567012345670L'
+ assert hex(0x1234567890ABCDEF) == '0x1234567890abcdef'
+ assert oct(01234567012345670) == '01234567012345670'
def test_bits(self):
x = 0xAAAAAAAAL
diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -287,10 +287,10 @@
def tofloat(self):
return _AsDouble(self)
- def format(self, digits, prefix='', suffix=''):
+ def format(self, digits, prefix=''):
# 'digits' is a string whose length is the base to use,
# and where each character is the corresponding digit.
- return _format(self, digits, prefix, suffix)
+ return _format(self, digits, prefix)
def repr(self):
return _format(self, BASE10)
@@ -603,10 +603,10 @@
if self.sign == 0:
return '0L'
else:
- return _format(self, BASE8, '0', 'L')
+ return _format(self, BASE8, '0')
def hex(self):
- return _format(self, BASE16, '0x', 'L')
+ return _format(self, BASE16, '0x')
def log(self, base):
# base is supposed to be positive or 0.0, which means we use e
@@ -1586,7 +1586,7 @@
BASE10 = '0123456789'
BASE16 = '0123456789abcdef'
-def _format(a, digits, prefix='', suffix=''):
+def _format(a, digits, prefix=''):
"""
Convert a bigint object to a string, using a given conversion base.
Return a string object.
@@ -1602,14 +1602,9 @@
while i > 1:
bits += 1
i >>= 1
- i = 5 + len(prefix) + len(suffix) + (size_a*SHIFT + bits-1) // bits
+ i = 5 + len(prefix) + (size_a*SHIFT + bits-1) // bits
s = [chr(0)] * i
p = i
- j = len(suffix)
- while j > 0:
- p -= 1
- j -= 1
- s[p] = suffix[j]
if a.sign == 0:
p -= 1
More information about the pypy-commit
mailing list