mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 13:09:49 +00:00
A couple more bugs found running 2.7 stdlib tests
This commit is contained in:
parent
f908e8dd8e
commit
37b8e21c76
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,7 +6,12 @@ def some_other_function():
|
|||||||
some_variable, = some_function()
|
some_variable, = some_function()
|
||||||
print(some_variable)
|
print(some_variable)
|
||||||
|
|
||||||
|
# From 2.7 test_compile.py
|
||||||
|
# Bug is adding erroneous parens in d[(1:2, 1:2)] += 1
|
||||||
|
def bug(d):
|
||||||
|
d[1:2, 1:2] += 1
|
||||||
|
|
||||||
empty_tup = ()
|
empty_tup = ()
|
||||||
one_item_tup = ("item1", )
|
one_item_tup = ("item1", )
|
||||||
one_item_tup_without_parentheses = "item",
|
one_item_tup_without_parentheses = "item",
|
||||||
many_items_tup = ("item1", "item2", "item3")
|
many_items_tup = ("item1", "item2", "item3")
|
||||||
|
@ -10,3 +10,9 @@
|
|||||||
def formatweekday(self):
|
def formatweekday(self):
|
||||||
with self as encoding:
|
with self as encoding:
|
||||||
return encoding
|
return encoding
|
||||||
|
|
||||||
|
# Bug in 2.7.14 test_contextlib.py. Bug was not enclosing (x,y) in parenthesis
|
||||||
|
def withas_bug(self, nested, a, b):
|
||||||
|
with self.assertRaises(ZeroDivisionError):
|
||||||
|
with nested(a(), b()) as (x, y):
|
||||||
|
1 // 0
|
||||||
|
@ -140,9 +140,9 @@ TABLE_DIRECT = {
|
|||||||
'binary_subscr': ( '%c[%p]',
|
'binary_subscr': ( '%c[%p]',
|
||||||
(0, 'expr'),
|
(0, 'expr'),
|
||||||
(1, 100) ),
|
(1, 100) ),
|
||||||
'binary_subscr2': ( '%c[%p]',
|
'binary_subscr2': ( '%c[%c]',
|
||||||
(0, 'expr'),
|
(0, 'expr'),
|
||||||
(1, 100) ),
|
(1, 'expr') ),
|
||||||
'store_subscr': ( '%c[%c]', 0, 1),
|
'store_subscr': ( '%c[%c]', 0, 1),
|
||||||
'STORE_FAST': ( '%{pattr}', ),
|
'STORE_FAST': ( '%{pattr}', ),
|
||||||
'STORE_NAME': ( '%{pattr}', ),
|
'STORE_NAME': ( '%{pattr}', ),
|
||||||
|
@ -315,8 +315,10 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
'importmultiple': ( '%|import %c%c\n', 2, 3 ),
|
'importmultiple': ( '%|import %c%c\n', 2, 3 ),
|
||||||
'import_cont' : ( ', %c', 2 ),
|
'import_cont' : ( ', %c', 2 ),
|
||||||
# With/as is allowed as "from future" thing in 2.5
|
# With/as is allowed as "from future" thing in 2.5
|
||||||
|
# Note: It is safe to put the variables after "as" in parenthesis,
|
||||||
|
# and sometimes it is needed.
|
||||||
'withstmt': ( '%|with %c:\n%+%c%-', 0, 3),
|
'withstmt': ( '%|with %c:\n%+%c%-', 0, 3),
|
||||||
'withasstmt': ( '%|with %c as %c:\n%+%c%-', 0, 2, 3),
|
'withasstmt': ( '%|with %c as (%c):\n%+%c%-', 0, 2, 3),
|
||||||
})
|
})
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
@ -1726,7 +1728,21 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
if lastnodetype.startswith('BUILD_LIST'):
|
if lastnodetype.startswith('BUILD_LIST'):
|
||||||
self.write('['); endchar = ']'
|
self.write('['); endchar = ']'
|
||||||
elif lastnodetype.startswith('BUILD_TUPLE'):
|
elif lastnodetype.startswith('BUILD_TUPLE'):
|
||||||
self.write('('); endchar = ')'
|
# Tuples can appear places that can NOT
|
||||||
|
# have parenthesis around them, like array
|
||||||
|
# subscripts. We check for that by seeing
|
||||||
|
# if a tuple item is some sort of slice.
|
||||||
|
no_parens = False
|
||||||
|
for n in node:
|
||||||
|
if n == 'expr' and n[0].kind.startswith('buildslice'):
|
||||||
|
no_parens = True
|
||||||
|
break
|
||||||
|
pass
|
||||||
|
if no_parens:
|
||||||
|
endchar = ''
|
||||||
|
else:
|
||||||
|
self.write('('); endchar = ')'
|
||||||
|
pass
|
||||||
elif lastnodetype.startswith('BUILD_SET'):
|
elif lastnodetype.startswith('BUILD_SET'):
|
||||||
self.write('{'); endchar = '}'
|
self.write('{'); endchar = '}'
|
||||||
elif lastnodetype.startswith('BUILD_MAP_UNPACK'):
|
elif lastnodetype.startswith('BUILD_MAP_UNPACK'):
|
||||||
|
Loading…
Reference in New Issue
Block a user