summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-08-18 16:29:54 (GMT)
committerGuido van Rossum <guido@python.org>2006-08-18 16:29:54 (GMT)
commitd2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 (patch)
tree40f4d5d4a9d117979b4d803a3fba0a17df3af699
parentf43127862d1c5d9e377ede09f86ab1e8f6dfab2f (diff)
downloadcpython-d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1.zip
cpython-d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1.tar.gz
cpython-d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1.tar.bz2
repr() of a long int no longer produces a trailing 'L'.
More unit tests probably need fixing; later...
-rw-r--r--Lib/test/test_long.py6
-rw-r--r--Objects/longobject.c22
2 files changed, 10 insertions, 18 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index 7b0c7b0..92fe7a1 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -196,7 +196,7 @@ class LongTest(unittest.TestCase):
def slow_format(self, x, base):
if (x, base) == (0, 8):
# this is an oddball!
- return "0L"
+ return "0"
digits = []
sign = 0
if x < 0:
@@ -208,7 +208,7 @@ class LongTest(unittest.TestCase):
digits = digits or [0]
return '-'[:sign] + \
{8: '0', 10: '', 16: '0x'}[base] + \
- "".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L"
+ "".join(map(lambda i: "0123456789abcdef"[i], digits))
def check_format_1(self, x):
for base, mapper in (8, oct), (10, repr), (16, hex):
@@ -221,7 +221,7 @@ class LongTest(unittest.TestCase):
# str() has to be checked a little differently since there's no
# trailing "L"
got = str(x)
- expected = self.slow_format(x, 10)[:-1]
+ expected = self.slow_format(x, 10)
msg = Frm("%s returned %r but expected %r for %r",
mapper.__name__, got, expected, x)
self.assertEqual(got, expected, msg)
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 9d3685e..a2690a2 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -35,7 +35,7 @@ static PyLongObject *long_normalize(PyLongObject *);
static PyLongObject *mul1(PyLongObject *, wdigit);
static PyLongObject *muladd1(PyLongObject *, wdigit, wdigit);
static PyLongObject *divrem1(PyLongObject *, digit, digit *);
-static PyObject *long_format(PyObject *aa, int base, int addL);
+static PyObject *long_format(PyObject *aa, int base);
#define SIGCHECK(PyTryBlock) \
if (--_Py_Ticker < 0) { \
@@ -1198,7 +1198,7 @@ divrem1(PyLongObject *a, digit n, digit *prem)
If base is 8 or 16, add the proper prefix '0' or '0x'. */
static PyObject *
-long_format(PyObject *aa, int base, int addL)
+long_format(PyObject *aa, int base)
{
register PyLongObject *a = (PyLongObject *)aa;
PyStringObject *str;
@@ -1222,14 +1222,12 @@ long_format(PyObject *aa, int base, int addL)
++bits;
i >>= 1;
}
- i = 5 + (addL ? 1 : 0) + (size_a*SHIFT + bits-1) / bits;
+ i = 5 + (size_a*SHIFT + bits-1) / bits;
str = (PyStringObject *) PyString_FromStringAndSize((char *)0, i);
if (str == NULL)
return NULL;
p = PyString_AS_STRING(str) + i;
*p = '\0';
- if (addL)
- *--p = 'L';
if (a->ob_size < 0)
sign = '-';
@@ -1890,13 +1888,7 @@ long_dealloc(PyObject *v)
static PyObject *
long_repr(PyObject *v)
{
- return long_format(v, 10, 1);
-}
-
-static PyObject *
-long_str(PyObject *v)
-{
- return long_format(v, 10, 0);
+ return long_format(v, 10);
}
static int
@@ -3255,13 +3247,13 @@ long_float(PyObject *v)
static PyObject *
long_oct(PyObject *v)
{
- return long_format(v, 8, 1);
+ return long_format(v, 8);
}
static PyObject *
long_hex(PyObject *v)
{
- return long_format(v, 16, 1);
+ return long_format(v, 16);
}
static PyObject *
@@ -3407,7 +3399,7 @@ PyTypeObject PyLong_Type = {
0, /* tp_as_mapping */
(hashfunc)long_hash, /* tp_hash */
0, /* tp_call */
- long_str, /* tp_str */
+ 0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */