mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
This commit is contained in:
parent
9b847b432c
commit
12e94200c0
4 changed files with 25 additions and 16 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue