summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-11-15 16:05:58 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-11-15 16:05:58 (GMT)
commitd15bb5fcad584e113836486d17c6abcbf2168a86 (patch)
tree42612d7712fa7c0cb9d448aa38f0279199be2680 /Lib
parent3864248866d6224336c7be49670447cb4d125cd6 (diff)
downloadcpython-d15bb5fcad584e113836486d17c6abcbf2168a86.zip
cpython-d15bb5fcad584e113836486d17c6abcbf2168a86.tar.gz
cpython-d15bb5fcad584e113836486d17c6abcbf2168a86.tar.bz2
bpo-32011: Revert "Issue GH-15480: Remove the deprecated and unused TYPE_INT64 code from marshal." (GH-4381) (#4405)
Simplify the reverted code. This reverts commit e9bbe8b87ba2874efba0474af5cc7d5941dbf742. (cherry picked from commit 00987f6230fcdbecc8d9ab4b2b9fae8f99a1a4a9)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_marshal.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index b378ffe..29dda98 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -34,6 +34,29 @@ class IntTestCase(unittest.TestCase, HelperMixin):
self.helper(expected)
n = n >> 1
+ def test_int64(self):
+ # Simulate int marshaling with TYPE_INT64.
+ maxint64 = (1 << 63) - 1
+ minint64 = -maxint64-1
+ for base in maxint64, minint64, -maxint64, -(minint64 >> 1):
+ while base:
+ s = b'I' + int.to_bytes(base, 8, 'little', signed=True)
+ got = marshal.loads(s)
+ self.assertEqual(base, got)
+ if base == -1: # a fixed-point for shifting right 1
+ base = 0
+ else:
+ base >>= 1
+
+ got = marshal.loads(b'I\xfe\xdc\xba\x98\x76\x54\x32\x10')
+ self.assertEqual(got, 0x1032547698badcfe)
+ got = marshal.loads(b'I\x01\x23\x45\x67\x89\xab\xcd\xef')
+ self.assertEqual(got, -0x1032547698badcff)
+ got = marshal.loads(b'I\x08\x19\x2a\x3b\x4c\x5d\x6e\x7f')
+ self.assertEqual(got, 0x7f6e5d4c3b2a1908)
+ got = marshal.loads(b'I\xf7\xe6\xd5\xc4\xb3\xa2\x91\x80')
+ self.assertEqual(got, -0x7f6e5d4c3b2a1909)
+
def test_bool(self):
for b in (True, False):
self.helper(b)