summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_marshal.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_marshal.py')
-rw-r--r--Lib/test/test_marshal.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 1e3520f..fb70ced 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -188,6 +188,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, float, complex, tuple, list, dict, set, frozenset):
+ # Note: str 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,