]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
repr() of a long int no longer produces a trailing 'L'.
authorGuido van Rossum <guido@python.org>
Fri, 18 Aug 2006 16:29:54 +0000 (16:29 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 18 Aug 2006 16:29:54 +0000 (16:29 +0000)
More unit tests probably need fixing; later...

Lib/test/test_long.py
Objects/longobject.c

index 7b0c7b0798a49f25c2b7f6612ae67a0641a345ee..92fe7a1b726449ccbf0dbab1d6ab2afabda410ff 100644 (file)
@@ -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)
index 9d3685e9a485091c7c2488a33b1d1747558982ce..a2690a26d198c4ab02f6343c5dec48f05bb7d806 100644 (file)
@@ -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 */