PYPY bugs and inspired changes ...

verify.py: Show co_flags when different.
pysource.py: PYPY also generates normal tryfinallystmt code
test_pyenvlib.py: allow pypy-5.3.1
This commit is contained in:
rocky
2016-08-27 19:32:42 -04:00
parent ddc5460030
commit f47aecae9f
3 changed files with 19 additions and 9 deletions

View File

@@ -27,8 +27,9 @@ from fnmatch import fnmatch
#----- configure this for your needs #----- configure this for your needs
TEST_VERSIONS=('2.3.7', '2.4.6', '2.5.6', '2.6.9', 'pypy-2.6.1', TEST_VERSIONS=('2.3.7', '2.4.6', '2.5.6', '2.6.9',
'pypy-5.0.1', 'pypy-2.4.0', 'pypy-2.6.1',
'pypy-5.0.1', 'pypy-5.3.1',
'2.7.10', '2.7.11', '2.7.10', '2.7.11',
'3.2.6', '3.3.5', '3.4.2', '3.5.1') '3.2.6', '3.3.5', '3.4.2', '3.5.1')

View File

@@ -312,12 +312,13 @@ TABLE_DIRECT = {
'forelselaststmtl': ( 'forelselaststmtl': (
'%|for %c in %c:\n%+%c%-%|else:\n%+%c%-\n\n', 3, 1, 4, -2), '%|for %c in %c:\n%+%c%-%|else:\n%+%c%-\n\n', 3, 1, 4, -2),
'trystmt': ( '%|try:\n%+%c%-%c\n\n', 1, 3 ), 'trystmt': ( '%|try:\n%+%c%-%c\n\n', 1, 3 ),
'tryelsestmt': ( '%|try:\n%+%c%-%c%|else:\n%+%c%-\n\n', 1, 3, 4 ), 'tryelsestmt': ( '%|try:\n%+%c%-%c%|else:\n%+%c%-\n\n', 1, 3, 4 ),
'tryelsestmtc': ( '%|try:\n%+%c%-%c%|else:\n%+%c%-', 1, 3, 4 ), 'tryelsestmtc': ( '%|try:\n%+%c%-%c%|else:\n%+%c%-', 1, 3, 4 ),
'tryelsestmtl': ( '%|try:\n%+%c%-%c%|else:\n%+%c%-', 1, 3, 4 ), 'tryelsestmtl': ( '%|try:\n%+%c%-%c%|else:\n%+%c%-', 1, 3, 4 ),
'tf_trystmt': ( '%c%-%c%+', 1, 3 ), 'tf_trystmt': ( '%c%-%c%+', 1, 3 ),
'tf_tryelsestmt': ( '%c%-%c%|else:\n%+%c', 1, 3, 4 ), 'tf_tryelsestmt': ( '%c%-%c%|else:\n%+%c', 1, 3, 4 ),
'except': ('%|except:\n%+%c%-', 3 ), 'tryfinallystmt': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 5 ),
'except': ( '%|except:\n%+%c%-', 3 ),
'except_cond1': ( '%|except %c:\n', 1 ), 'except_cond1': ( '%|except %c:\n', 1 ),
'except_cond2': ( '%|except %c as %c:\n', 1, 5 ), 'except_cond2': ( '%|except %c as %c:\n', 1, 5 ),
'except_suite': ( '%+%c%-%C', 0, (1, maxint, '') ), 'except_suite': ( '%+%c%-%C', 0, (1, maxint, '') ),
@@ -533,7 +534,6 @@ class SourceWalker(GenericASTTraversal, object):
'assert': ( '%|assert %c\n' , 0 ), 'assert': ( '%|assert %c\n' , 0 ),
'assert2': ( '%|assert %c, %c\n' , 0, 3 ), 'assert2': ( '%|assert %c, %c\n' , 0, 3 ),
'trystmt': ( '%|try:\n%+%c%-%c\n\n', 1, 3 ), 'trystmt': ( '%|try:\n%+%c%-%c\n\n', 1, 3 ),
'tryfinallystmt': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 5 ),
'assign2': ( '%|%c, %c = %c, %c\n', 3, 4, 0, 1 ), 'assign2': ( '%|%c, %c = %c, %c\n', 3, 4, 0, 1 ),
'assign3': ( '%|%c, %c, %c = %c, %c, %c\n', 5, 6, 7, 0, 1, 2 ), 'assign3': ( '%|%c, %c, %c = %c, %c, %c\n', 5, 6, 7, 0, 1, 2 ),
}) })

View File

@@ -16,6 +16,7 @@ from uncompyle6 import PYTHON3
from xdis.code import iscode from xdis.code import iscode
from xdis.magics import PYTHON_MAGIC_INT from xdis.magics import PYTHON_MAGIC_INT
from xdis.load import load_file, load_module from xdis.load import load_file, load_module
from xdis.util import pretty_flags
# FIXME: DRY # FIXME: DRY
if PYTHON3: if PYTHON3:
@@ -335,6 +336,14 @@ def cmp_code_objects(version, is_pypy, code_obj1, code_obj2, name=''):
for c1, c2 in zip(codes1, codes2): for c1, c2 in zip(codes1, codes2):
cmp_code_objects(version, is_pypy, c1, c2, name=name) cmp_code_objects(version, is_pypy, c1, c2, name=name)
elif member == 'co_flags':
# For PYPY for now we don't care about PYPY_SOURCE_IS_UTF8:
flags1 = code_obj1.co_flags | 0x0100 # PYPY_SOURCE_IS_UTF8
flags2 = code_obj2.co_flags
if flags1 != flags2:
raise CmpErrorMember(name, 'co_flags',
pretty_flags(flags1),
pretty_flags(flags2))
else: else:
# all other members must be equal # all other members must be equal
if getattr(code_obj1, member) != getattr(code_obj2, member): if getattr(code_obj1, member) != getattr(code_obj2, member):