Pypy 2.7 fixes

* pypy doesn't seem to grok sys.stdout.flush() sometimes?
* pypy has extra come_froms for return_if_stmt
This commit is contained in:
rocky
2019-01-05 13:21:24 -05:00
parent 37750814b9
commit 1a70f75ffc
2 changed files with 20 additions and 3 deletions

View File

@@ -315,10 +315,19 @@ def main(in_base, out_base, files, codes, outfile=None,
sys.stdout.write("%s\r" %
status_msg(do_verify, tot_files, okay_files, failed_files,
verify_failed_files, do_verify))
sys.stdout.flush()
try:
# FIXME: Something is weird with Pypy here
sys.stdout.flush()
except:
pass
if current_outfile:
sys.stdout.write("\n")
sys.stdout.flush()
try:
# FIXME: Something is weird with Pypy here
sys.stdout.flush()
except:
pass
pass
return (tot_files, okay_files, failed_files, verify_failed_files)

View File

@@ -3,7 +3,8 @@
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from uncompyle6.parser import PythonParserSingle
from xdis import next_offset
from uncompyle6.parser import PythonParserSingle, nop_func
from uncompyle6.parsers.parse2 import Python2Parser
class Python27Parser(Python2Parser):
@@ -196,6 +197,13 @@ class Python27Parser(Python2Parser):
POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt
END_FINALLY
""")
if 'PyPy' in customize:
# PyPy-specific customizations
self.addRule("""
return_if_stmt ::= ret_expr RETURN_END_IF come_froms
""", nop_func)
super(Python27Parser, self).customize_grammar_rules(tokens, customize)
self.check_reduce['and'] = 'AST'
# self.check_reduce['or'] = 'AST'