]> granicus.if.org Git - python/commitdiff
Issue #15480: Remove the deprecated and unused TYPE_INT64 code from marshal.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 13 Apr 2013 20:41:09 +0000 (22:41 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 13 Apr 2013 20:41:09 +0000 (22:41 +0200)
Initial patch by Daniel Riti.

Lib/test/test_marshal.py
Misc/ACKS
Misc/NEWS
Python/marshal.c

index c817cafa57521c9d27c824c06bbb98c6eed434a4..7c52ee3c8a68db26a053c39c3569970281abb657 100644 (file)
@@ -23,36 +23,12 @@ class HelperMixin:
 
 class IntTestCase(unittest.TestCase, HelperMixin):
     def test_ints(self):
-        # Test the full range of Python ints.
-        n = sys.maxsize
+        # Test a range of Python ints larger than the machine word size.
+        n = sys.maxsize ** 2
         while n:
             for expected in (-n, n):
                 self.helper(expected)
-            n = n >> 1
-
-    def test_int64(self):
-        # Simulate int marshaling on a 64-bit box.  This is most interesting if
-        # we're running the test on a 32-bit box, of course.
-
-        def to_little_endian_string(value, nbytes):
-            b = bytearray()
-            for i in range(nbytes):
-                b.append(value & 0xff)
-                value >>= 8
-            return b
-
-        maxint64 = (1 << 63) - 1
-        minint64 = -maxint64-1
-
-        for base in maxint64, minint64, -maxint64, -(minint64 >> 1):
-            while base:
-                s = b'I' + to_little_endian_string(base, 8)
-                got = marshal.loads(s)
-                self.assertEqual(base, got)
-                if base == -1:  # a fixed-point for shifting right 1
-                    base = 0
-                else:
-                    base >>= 1
+                n = n >> 1
 
     def test_bool(self):
         for b in (True, False):
index da250f425cfafb25db7a59f14520e8f14edb48f5..ac8733f7168cb6b38516568ea7bfb3e263b5320a 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1024,6 +1024,7 @@ Nicholas Riley
 Jean-Claude Rimbault
 Vlad Riscutia
 Wes Rishel
+Daniel Riti
 Juan M. Bello Rivas
 Davide Rizzo
 Anthony Roach
index 1889ac25d0cddb630488db468170049dacac8299..b0a65957faca1079ef3601e3ef92b8c780fd0d80 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #15480: Remove the deprecated and unused TYPE_INT64 code from marshal.
+  Initial patch by Daniel Riti.
+
 - Issue #2118: SMTPException is now a subclass of IOError.
 
 - Issue #17016: Get rid of possible pointer wraparounds and integer overflows
index bd889393d146d470e8ea960a8f64ad9ed1299976..3e13851704801efa08c1b0b2a1f5350589ed1ffb 100644 (file)
 #define TYPE_STOPITER           'S'
 #define TYPE_ELLIPSIS           '.'
 #define TYPE_INT                'i'
-/* TYPE_INT64 is deprecated. It is not
-   generated anymore, and support for reading it
-   will be removed in Python 3.4. */
-#define TYPE_INT64              'I'
 #define TYPE_FLOAT              'f'
 #define TYPE_BINARY_FLOAT       'g'
 #define TYPE_COMPLEX            'x'
@@ -638,42 +634,6 @@ r_long(RFILE *p)
     return x;
 }
 
-/* r_long64 deals with the TYPE_INT64 code.  On a machine with
-   sizeof(long) > 4, it returns a Python int object, else a Python long
-   object.  Note that w_long64 writes out TYPE_INT if 32 bits is enough,
-   so there's no inefficiency here in returning a PyLong on 32-bit boxes
-   for everything written via TYPE_INT64 (i.e., if an int is written via
-   TYPE_INT64, it *needs* more than 32 bits).
-*/
-static PyObject *
-r_long64(RFILE *p)
-{
-    PyObject *result = NULL;
-    long lo4 = r_long(p);
-    long hi4 = r_long(p);
-
-    if (!PyErr_Occurred()) {
-#if SIZEOF_LONG > 4
-        long x = (hi4 << 32) | (lo4 & 0xFFFFFFFFL);
-        result = PyLong_FromLong(x);
-#else
-        unsigned char buf[8];
-        int one = 1;
-        int is_little_endian = (int)*(char*)&one;
-        if (is_little_endian) {
-            memcpy(buf, &lo4, 4);
-            memcpy(buf+4, &hi4, 4);
-        }
-        else {
-            memcpy(buf, &hi4, 4);
-            memcpy(buf+4, &lo4, 4);
-        }
-        result = _PyLong_FromByteArray(buf, 8, is_little_endian, 1);
-#endif
-    }
-    return result;
-}
-
 static PyObject *
 r_PyLong(RFILE *p)
 {
@@ -871,11 +831,6 @@ r_object(RFILE *p)
         R_REF(retval);
         break;
 
-    case TYPE_INT64:
-        retval = r_long64(p);
-        R_REF(retval);
-        break;
-
     case TYPE_LONG:
         retval = r_PyLong(p);
         R_REF(retval);
@@ -1201,7 +1156,7 @@ r_object(RFILE *p)
             PyObject *name = NULL;
             int firstlineno;
             PyObject *lnotab = NULL;
-            
+
             idx = r_ref_reserve(flag, p);
             if (idx < 0) {
                 retval = NULL;