You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Handle marshal frozenset
This commit is contained in:
@@ -18,3 +18,11 @@ def test_load_module():
|
|||||||
version, timestamp, magic_int, co = load_module(mod_file)
|
version, timestamp, magic_int, co = load_module(mod_file)
|
||||||
assert version == 2.5, "Should have picked up Python version properly"
|
assert version == 2.5, "Should have picked up Python version properly"
|
||||||
assert co.co_consts == (5j, None), "Code should have a complex constant"
|
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)
|
raise KeyError(marshalType)
|
||||||
elif marshalType in ['<', '>']:
|
elif marshalType in ['<', '>']:
|
||||||
# set and frozenset
|
# set and frozenset
|
||||||
raise KeyError(marshalType)
|
setsize = unpack('i', fp.read(4))[0]
|
||||||
return None
|
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':
|
elif marshalType == 'a':
|
||||||
# ascii
|
# ascii
|
||||||
# FIXME check
|
# FIXME check
|
||||||
|
Reference in New Issue
Block a user