mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 13:09:49 +00:00
Fix "or" bug in 2.6- seen via chained comparisons
This commit is contained in:
parent
fcceda72db
commit
acc3e441ac
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
|
||||
# compare_chained2 ::= expr COMPARE_OP RETURN_VALUE
|
||||
|
||||
def _is_valid_netmask(self, netmask):
|
||||
return 0 <= netmask <= self._max_prefixlen
|
||||
# Seen in Python 3.3 ipaddress.py
|
||||
|
||||
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
|
||||
# possibly I am "skipping over" a "pass" or null statement.
|
||||
|
||||
test_target = target
|
||||
if self.version < 2.7:
|
||||
op_testset = set([self.opc.POP_TOP,
|
||||
self.opc.JUMP_IF_TRUE, self.opc.JUMP_IF_FALSE])
|
||||
# Before 2.6 we have to deal with the fact that there is an extra
|
||||
# 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:
|
||||
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
|
||||
and (target > offset) ):
|
||||
if ( code[pre[test_target]] in test_set and target > offset ):
|
||||
self.fixed_jumps[offset] = pre[target]
|
||||
self.structs.append({'type': 'and/or',
|
||||
'start': start,
|
||||
'end': pre[target]})
|
||||
'start': start,
|
||||
'end': pre[target]})
|
||||
return
|
||||
|
||||
# The op offset just before the target jump offset is important
|
||||
|
Loading…
Reference in New Issue
Block a user