You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Fix "or" bug in 2.6- seen via chained comparisons
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,13 @@
|
|||||||
# In Python 3.3+ this uses grammar rule
|
# In Python 3.3+ this uses grammar rule
|
||||||
# compare_chained2 ::= expr COMPARE_OP RETURN_VALUE
|
# compare_chained2 ::= expr COMPARE_OP RETURN_VALUE
|
||||||
|
|
||||||
def _is_valid_netmask(self, netmask):
|
# Seen in Python 3.3 ipaddress.py
|
||||||
return 0 <= netmask <= self._max_prefixlen
|
|
||||||
|
def _is_valid_netmask(netmask):
|
||||||
|
return 0 <= netmask <= 10
|
||||||
|
|
||||||
|
# There were also bugs in 2.6- involving the use of "or" twice in its "or"
|
||||||
|
# detections
|
||||||
|
|
||||||
|
# See in 2.6.9 quopri.py ishex():
|
||||||
|
'0' <= __file__ <= '9' or 'a' <= __file__ <= 'f' or 'A' <= __file__ <= 'F'
|
||||||
|
@@ -711,18 +711,22 @@ class Scanner2(Scanner):
|
|||||||
# rocky: if we have a conditional jump to the next instruction, then
|
# rocky: if we have a conditional jump to the next instruction, then
|
||||||
# possibly I am "skipping over" a "pass" or null statement.
|
# possibly I am "skipping over" a "pass" or null statement.
|
||||||
|
|
||||||
|
test_target = target
|
||||||
if self.version < 2.7:
|
if self.version < 2.7:
|
||||||
op_testset = set([self.opc.POP_TOP,
|
# Before 2.6 we have to deal with the fact that there is an extra
|
||||||
self.opc.JUMP_IF_TRUE, self.opc.JUMP_IF_FALSE])
|
# POP_TOP that is logically associated with the JUMP_IF's (even though
|
||||||
|
# the instance set is called "self.pop_jump_if")
|
||||||
|
if code[pre[test_target]] == self.opc.POP_TOP:
|
||||||
|
test_target = pre[test_target]
|
||||||
|
test_set = self.pop_jump_if
|
||||||
else:
|
else:
|
||||||
op_testset = self.pop_jump_if_or_pop | self.pop_jump_if
|
test_set = self.pop_jump_if_or_pop | self.pop_jump_if
|
||||||
|
|
||||||
if ( code[pre[target]] in op_testset
|
if ( code[pre[test_target]] in test_set and target > offset ):
|
||||||
and (target > offset) ):
|
|
||||||
self.fixed_jumps[offset] = pre[target]
|
self.fixed_jumps[offset] = pre[target]
|
||||||
self.structs.append({'type': 'and/or',
|
self.structs.append({'type': 'and/or',
|
||||||
'start': start,
|
'start': start,
|
||||||
'end': pre[target]})
|
'end': pre[target]})
|
||||||
return
|
return
|
||||||
|
|
||||||
# The op offset just before the target jump offset is important
|
# The op offset just before the target jump offset is important
|
||||||
|
Reference in New Issue
Block a user