diff options
author | Raymond Hettinger <python@rcn.com> | 2007-11-07 01:13:09 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-11-07 01:13:09 (GMT) |
commit | 12e94200c0b12487e129ce7e325d9315c12ca88a (patch) | |
tree | 0cbe02ff1f2a163d2e2c3c2cfb496f73e8c108e7 /Lib | |
parent | 9b847b432cda06cb1c1fd58a46efb7f0eca1cad1 (diff) | |
download | cpython-12e94200c0b12487e129ce7e325d9315c12ca88a.zip cpython-12e94200c0b12487e129ce7e325d9315c12ca88a.tar.gz cpython-12e94200c0b12487e129ce7e325d9315c12ca88a.tar.bz2 |
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_marshal.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 656fc1f..1b2c8b7 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -244,6 +244,17 @@ class BugsTestCase(unittest.TestCase): last.append([0]) self.assertRaises(ValueError, marshal.dumps, head) + def test_exact_type_match(self): + # Former bug: + # >>> class Int(int): pass + # >>> type(loads(dumps(Int()))) + # <type 'int'> + for typ in (int, long, float, complex, tuple, list, dict, set, frozenset): + # Note: str and unicode sublclasses are not tested because they get handled + # by marshal's routines for objects supporting the buffer API. + subtyp = type('subtyp', (typ,), {}) + self.assertRaises(ValueError, marshal.dumps, subtyp()) + def test_main(): test_support.run_unittest(IntTestCase, FloatTestCase, |