You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 2.5 was missing try else stmt
This commit is contained in:
@@ -98,21 +98,6 @@ check-bytecode-2.4:
|
||||
check-bytecode-2.5:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-2.5
|
||||
|
||||
#: Get grammar coverage for Python 2.5
|
||||
grammar-coverage-2.5:
|
||||
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-25.cover $(PYTHON) test_pythonlib.py --bytecode-2.5
|
||||
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-25.cover $(PYTHON) test_pyenvlib.py --2.5.6
|
||||
|
||||
#: Get grammar coverage for Python 2.6
|
||||
grammar-coverage-2.6:
|
||||
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-26.cover $(PYTHON) test_pythonlib.py --bytecode-2.6
|
||||
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-26.cover $(PYTHON) test_pyenvlib.py --2.6.9
|
||||
|
||||
#: Get grammar coverage for Python 2.7
|
||||
grammar-coverage-2.7:
|
||||
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-27.cover $(PYTHON) test_pythonlib.py --bytecode-2.7
|
||||
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-27.cover $(PYTHON) test_pyenvlib.py --2.7.13
|
||||
|
||||
#: Check deparsing Python 3.0
|
||||
check-bytecode-3.0:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.0
|
||||
|
Binary file not shown.
@@ -1,7 +1,6 @@
|
||||
# Python 2.5 bug
|
||||
# Was turning into tryelse when there in fact is no else.
|
||||
def options(self, section):
|
||||
"""Return a list of option names for the given section name."""
|
||||
try:
|
||||
opts = self._sections[section].copy()
|
||||
except KeyError:
|
||||
@@ -10,3 +9,19 @@ def options(self, section):
|
||||
if '__name__' in opts:
|
||||
del opts['__name__']
|
||||
return opts.keys()
|
||||
|
||||
# From python2.5/distutils/command/register.py
|
||||
def post_to_server(self, urllib2):
|
||||
try:
|
||||
result = 5
|
||||
except urllib2.HTTPError, e:
|
||||
result = e.code, e.msg
|
||||
except urllib2.URLError, e:
|
||||
result = 500
|
||||
else:
|
||||
if self.show_response:
|
||||
result = 10
|
||||
result = 200
|
||||
if self.show_response:
|
||||
result = 8
|
||||
return result
|
||||
|
@@ -27,7 +27,10 @@ class Python25Parser(Python26Parser):
|
||||
store ::= STORE_FAST
|
||||
store ::= STORE_NAME
|
||||
|
||||
# Python 2.6 omits ths LOAD_FAST DELETE_FAST below
|
||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
try_middle else_suite COME_FROM
|
||||
|
||||
# Python 2.6 omits the LOAD_FAST DELETE_FAST below
|
||||
# withas is allowed as a "from future" in 2.5
|
||||
withasstmt ::= expr setupwithas designator suite_stmts_opt
|
||||
POP_BLOCK LOAD_CONST COME_FROM
|
||||
@@ -48,18 +51,6 @@ class Python25Parser(Python26Parser):
|
||||
tokens, first, last)
|
||||
if invalid:
|
||||
return invalid
|
||||
lhs = rule[0]
|
||||
if lhs in ('tryelsestmt', ):
|
||||
# The end of the else part of try/else come_from has to come
|
||||
# from an END_FINALLY statement
|
||||
if tokens[last-1].type.startswith('COME_FROM'):
|
||||
end_finally_offset = int(tokens[last-1].pattr)
|
||||
current = first
|
||||
while current < last:
|
||||
offset = tokens[current].offset
|
||||
if offset == end_finally_offset:
|
||||
return tokens[current].type != 'END_FINALLY'
|
||||
current += 1
|
||||
return False
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user