mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-30 16:40:48 +00:00
Handle marshal frozenset
This commit is contained in:
parent
fbcdc7a181
commit
1121ff2456
@ -18,3 +18,11 @@ def test_load_module():
|
||||
version, timestamp, magic_int, co = load_module(mod_file)
|
||||
assert version == 2.5, "Should have picked up Python version properly"
|
||||
assert co.co_consts == (5j, None), "Code should have a complex constant"
|
||||
|
||||
mod_file = os.path.join(get_srcdir(), '..', 'test', 'bytecode_3.3',
|
||||
'06_frozenset.pyc')
|
||||
version, timestamp, magic_int, co = load_module(mod_file)
|
||||
print(co.co_consts)
|
||||
expect = (0, None, 'attlist', 'linktype', 'link', 'element', 'Yep',
|
||||
frozenset({'linktype', 'attlist', 'element', 'link'}))
|
||||
assert co.co_consts == expect, "Should handle frozenset"
|
||||
|
BIN
test/bytecode_3.3/06_frozenset.pyc
Normal file
BIN
test/bytecode_3.3/06_frozenset.pyc
Normal file
Binary file not shown.
5
test/simple_source/expression/06_frozenset.py
Normal file
5
test/simple_source/expression/06_frozenset.py
Normal file
@ -0,0 +1,5 @@
|
||||
# Bug from Python 3.3 _markupbase.py cross compilatin
|
||||
# error in unmarshaling a frozenset
|
||||
import sys
|
||||
if sys.argv[0] in {"attlist", "linktype", "link", "element"}:
|
||||
print("Yep")
|
@ -258,8 +258,15 @@ def load_code_internal(fp, magic_int, bytes_for_s=False,
|
||||
raise KeyError(marshalType)
|
||||
elif marshalType in ['<', '>']:
|
||||
# set and frozenset
|
||||
raise KeyError(marshalType)
|
||||
return None
|
||||
setsize = unpack('i', fp.read(4))[0]
|
||||
ret = tuple()
|
||||
while setsize > 0:
|
||||
ret += load_code_internal(fp, magic_int, code_objects=code_objects),
|
||||
setsize -= 1
|
||||
if marshalType == '>':
|
||||
return frozenset(ret)
|
||||
else:
|
||||
return set(ret)
|
||||
elif marshalType == 'a':
|
||||
# ascii
|
||||
# FIXME check
|
||||
|
Loading…
Reference in New Issue
Block a user