diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-16 19:43:46 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-16 19:43:46 +0200 |
commit | 707b5ccde56e89162660d7aaae584eeaf2736120 (patch) | |
tree | 719fe88e870eee24451dd4935d1f5df1be5158ec /Lib/test/test_descr.py | |
parent | 01bdd9a98070f12ad27611a37db91fd5ecae7358 (diff) | |
download | cpython-git-707b5ccde56e89162660d7aaae584eeaf2736120.tar.gz |
Issue #22783: Pickling now uses the NEWOBJ opcode instead of the NEWOBJ_EX
opcode if possible.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 39782a41f7..0c88fd282e 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4592,26 +4592,15 @@ class PicklingTests(unittest.TestCase): def _check_reduce(self, proto, obj, args=(), kwargs={}, state=None, listitems=None, dictitems=None): - if proto >= 4: + if proto >= 2: reduce_value = obj.__reduce_ex__(proto) - self.assertEqual(reduce_value[:3], - (copyreg.__newobj_ex__, - (type(obj), args, kwargs), - state)) - if listitems is not None: - self.assertListEqual(list(reduce_value[3]), listitems) - else: - self.assertIsNone(reduce_value[3]) - if dictitems is not None: - self.assertDictEqual(dict(reduce_value[4]), dictitems) + if kwargs: + self.assertEqual(reduce_value[0], copyreg.__newobj_ex__) + self.assertEqual(reduce_value[1], (type(obj), args, kwargs)) else: - self.assertIsNone(reduce_value[4]) - elif proto >= 2: - reduce_value = obj.__reduce_ex__(proto) - self.assertEqual(reduce_value[:3], - (copyreg.__newobj__, - (type(obj),) + args, - state)) + self.assertEqual(reduce_value[0], copyreg.__newobj__) + self.assertEqual(reduce_value[1], (type(obj),) + args) + self.assertEqual(reduce_value[2], state) if listitems is not None: self.assertListEqual(list(reduce_value[3]), listitems) else: |