You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Add rule for 3.x comp_for
This commit is contained in:
BIN
test/bytecode_3.6_run/08_comp_gen_for.pyc
Normal file
BIN
test/bytecode_3.6_run/08_comp_gen_for.pyc
Normal file
Binary file not shown.
18
test/simple_source/bug36/08_comp_gen_for.py
Normal file
18
test/simple_source/bug36/08_comp_gen_for.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Bug in 3.3 weakset
|
||||
# Bug was not having a rule for 3.x "comp_for"
|
||||
|
||||
class WeakSet:
|
||||
def __init__(self, data=None):
|
||||
self.data = set(data)
|
||||
|
||||
def __iter__(self):
|
||||
for item in self.data:
|
||||
if item is not None:
|
||||
yield item
|
||||
|
||||
def union(self, other):
|
||||
return self.__class__(e for s in (self, other) for e in s)
|
||||
|
||||
a = WeakSet([1, 2, 3])
|
||||
b = WeakSet([1, 3, 5])
|
||||
assert list(a.union(b)) == [1, 2, 3, 5]
|
@@ -186,9 +186,9 @@ TABLE_DIRECT = {
|
||||
'comp_if': ( ' if %c%c', 0, 2 ),
|
||||
'comp_if_not': ( ' if not %p%c', (0, 22), 2 ),
|
||||
'comp_body': ( '', ), # ignore when recusing
|
||||
'set_comp_body': ( '%c', 0 ),
|
||||
'gen_comp_body': ( '%c', 0 ),
|
||||
'dict_comp_body': ( '%c:%c', 1, 0 ),
|
||||
'set_comp_body': ( '%c', 0 ),
|
||||
'gen_comp_body': ( '%c', 0 ),
|
||||
'dict_comp_body': ( '%c:%c', 1, 0 ),
|
||||
|
||||
'assign': ( '%|%c = %p\n', -1, (0, 200) ),
|
||||
|
||||
|
@@ -29,6 +29,8 @@ def customize_for_version3(self, version):
|
||||
TABLE_DIRECT.update({
|
||||
'except_cond2': ( '%|except %c as %c:\n', 1, 5 ),
|
||||
'function_def_annotate': ( '\n\n%|def %c%c\n', -1, 0),
|
||||
'comp_for' : ( ' for %c in %c',
|
||||
(2, 'store') , (0, 'expr') ),
|
||||
'importmultiple': ( '%|import %c%c\n', 2, 3 ),
|
||||
'import_cont' : ( ', %c', 2 ),
|
||||
'store_locals': ( '%|# inspect.currentframe().f_locals = __locals__\n', ),
|
||||
|
Reference in New Issue
Block a user