Merge branch 'python-3.3-to-3.5' into python-2.4

This commit is contained in:
rocky
2022-11-03 15:26:21 -04:00

View File

@@ -38,7 +38,7 @@ class Scanner30(Scanner3):
start = parent["start"]
end = parent["end"]
# Pick inner-most parent for our offset
# Pick innermost parent for our offset
for struct in self.structs:
current_start = struct["start"]
current_end = struct["end"]
@@ -191,7 +191,7 @@ class Scanner30(Scanner3):
# Is it an "and" inside an "if" or "while" block
if op == opc.JUMP_IF_FALSE:
# Search for another JUMP_IF_FALSE targetting the same op,
# Search for another JUMP_IF_FALSE targeting the same op,
# in current statement, starting from current offset, and filter
# everything inside inner 'or' jumps and midline ifs
match = self.rem_or(
@@ -346,7 +346,7 @@ class Scanner30(Scanner3):
if if_end > start:
return
end = self.restrict_to_parent(if_end, parent)
self.restrict_to_parent(if_end, parent)
self.structs.append(
{"type": "if-then", "start": start, "end": pre_rtarget}
@@ -370,13 +370,13 @@ class Scanner30(Scanner3):
self.not_continue.add(pre_rtarget)
elif code[pre_rtarget] in (self.opc.RETURN_VALUE, self.opc.BREAK_LOOP):
self.structs.append({"type": "if-then", "start": start, "end": rtarget})
# It is important to distingish if this return is inside some sort
# It is important to distinguish if this return is inside some sort
# except block return
jump_prev = prev_op[offset]
if self.is_pypy and code[jump_prev] == self.opc.COMPARE_OP:
if self.opc.cmp_op[code[jump_prev + 1]] == "exception-match":
return
if self.version >= 3.5:
if self.version >= (3, 5):
# Python 3.5 may remove as dead code a JUMP
# instruction after a RETURN_VALUE. So we check
# based on seeing SETUP_EXCEPT various places.
@@ -397,7 +397,7 @@ class Scanner30(Scanner3):
pass
pass
if code[pre_rtarget] == self.opc.RETURN_VALUE:
if self.version == 3.0:
if self.version == (3, 0):
next_op = rtarget
if code[next_op] == self.opc.POP_TOP:
next_op = rtarget
@@ -435,7 +435,7 @@ class Scanner30(Scanner3):
self.fixed_jumps[offset] = self.restrict_to_parent(target, parent)
pass
pass
elif self.version >= 3.5:
elif self.version >= (3, 5):
# 3.5+ has Jump optimization which too often causes RETURN_VALUE to get
# misclassified as RETURN_END_IF. Handle that here.
# In RETURN_VALUE, JUMP_ABSOLUTE, RETURN_VALUE is never RETURN_END_IF