diff --git a/test/simple_source/bug25/02_try_else.py b/test/simple_source/bug25/02_try_else.py index 5c708c31..f2325ff8 100644 --- a/test/simple_source/bug25/02_try_else.py +++ b/test/simple_source/bug25/02_try_else.py @@ -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 diff --git a/uncompyle6/parsers/parse25.py b/uncompyle6/parsers/parse25.py index 4d17dc9a..8111ff93 100644 --- a/uncompyle6/parsers/parse25.py +++ b/uncompyle6/parsers/parse25.py @@ -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