From 82bc294995316d3b6db8b7564dfed09cdc5e3893 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 4 Jun 2018 08:54:09 -0400 Subject: [PATCH] Improve Python 1.4 bytecode coverage --- test/bytecode_1.4/01_print-1.4.pyc | Bin 0 -> 338 bytes .../{test_class-1.4.pyc => test_class.pyc} | Bin test/bytecode_1.4/test_del-1.4.pyc | Bin 784 -> 0 bytes ...t_docstring-1.4.pyc => test_docstring.pyc} | Bin test/bytecode_1.4/test_empty-1.4.pyc | Bin 79 -> 0 bytes test/bytecode_1.4/test_empty.pyc | Bin 0 -> 77 bytes test/bytecode_1.4/test_exec.pyc | Bin 0 -> 176 bytes .../{test_global-1.4.pyc => test_global.pyc} | Bin ...{test_globals-1.4.pyc => test_globals.pyc} | Bin ...ngle_stmt-1.4.pyc => test_single_stmt.pyc} | Bin test/bytecode_1.5/exec.pyc | Bin 176 -> 0 bytes test/simple_source/bug14/01_print.py | 5 ++++ test/stdlib/compile-file.py | 1 + test/stdlib/compile_file_1x.py | 22 ++++++++++++++++++ uncompyle6/parsers/parse14.py | 2 ++ uncompyle6/scanners/scanner14.py | 4 ++-- 16 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/bytecode_1.4/01_print-1.4.pyc rename test/bytecode_1.4/{test_class-1.4.pyc => test_class.pyc} (100%) delete mode 100644 test/bytecode_1.4/test_del-1.4.pyc rename test/bytecode_1.4/{test_docstring-1.4.pyc => test_docstring.pyc} (100%) delete mode 100644 test/bytecode_1.4/test_empty-1.4.pyc create mode 100644 test/bytecode_1.4/test_empty.pyc create mode 100644 test/bytecode_1.4/test_exec.pyc rename test/bytecode_1.4/{test_global-1.4.pyc => test_global.pyc} (100%) rename test/bytecode_1.4/{test_globals-1.4.pyc => test_globals.pyc} (100%) rename test/bytecode_1.4/{test_single_stmt-1.4.pyc => test_single_stmt.pyc} (100%) delete mode 100644 test/bytecode_1.5/exec.pyc create mode 100644 test/simple_source/bug14/01_print.py create mode 100755 test/stdlib/compile_file_1x.py diff --git a/test/bytecode_1.4/01_print-1.4.pyc b/test/bytecode_1.4/01_print-1.4.pyc new file mode 100644 index 0000000000000000000000000000000000000000..90be8c44294c42942c1d47300eaf33f781e7bc20 GIT binary patch literal 338 zcma)$KMTSz5XE29`mf?7;wny=S`~N4I=Q&%P-+vUsBOvBK@ht5{rpN^L{K+F$h~{q z?_IoM&woq?+Z3-ueJ(X$0R`NF4WJyXrC>i55O6^=J0noLxB;1iq6>!`o{RD}OAksQ zsvA%)q8qzQ&RR>4u@yD>JtyX<4YfX!eAZb`l}^;C*h`mNvHxW4hcxf3e;YZDvoeMNZ}L?EANieSnS%XwWBDfm5};B z_RA`;q#Z~ z2y_du1A|!`nq$B&lPB1<`LjN+%zw^Bats7*#o4p4&c5+hF5@xT#{S;5igl@=@sBHmtM!x3G?@D zKpKQU&r6(UgL^Se*yZRy|4fP diff --git a/test/bytecode_1.4/test_docstring-1.4.pyc b/test/bytecode_1.4/test_docstring.pyc similarity index 100% rename from test/bytecode_1.4/test_docstring-1.4.pyc rename to test/bytecode_1.4/test_docstring.pyc diff --git a/test/bytecode_1.4/test_empty-1.4.pyc b/test/bytecode_1.4/test_empty-1.4.pyc deleted file mode 100644 index 8c8d8b487c34eec089f54b1f2012628c38fd57a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79 zcmZP(=jCF3xgaW;0St=SfmA&MLka^!um&TL?WX|}2NT7TK$d<a(-?>WlpMoNosLP Rd}?k%Nu^#vWid#tJpl0f4~PH& literal 0 HcmV?d00001 diff --git a/test/bytecode_1.4/test_exec.pyc b/test/bytecode_1.4/test_exec.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ef47f8626d02c0881ea2cd6146094554d0c554b5 GIT binary patch literal 176 zcmZP(=jCF3xgaW;0St<5fK)vYaWbSZFhl_v+zhD<3@MBZETQ#0AZ98fLo)-2$BW>l zGJ(WGfvSQvn1BWpvjK@j1zQC}BR>shkN^jeC`m0YNzPA6EoKLD(sS~Y5_5{dDs%Fa nflLjcC_}LrkVr{Q&d)8V%t_S;X^Bs*NKMu&s4Qj#O4$PdbqOO{ literal 0 HcmV?d00001 diff --git a/test/bytecode_1.4/test_global-1.4.pyc b/test/bytecode_1.4/test_global.pyc similarity index 100% rename from test/bytecode_1.4/test_global-1.4.pyc rename to test/bytecode_1.4/test_global.pyc diff --git a/test/bytecode_1.4/test_globals-1.4.pyc b/test/bytecode_1.4/test_globals.pyc similarity index 100% rename from test/bytecode_1.4/test_globals-1.4.pyc rename to test/bytecode_1.4/test_globals.pyc diff --git a/test/bytecode_1.4/test_single_stmt-1.4.pyc b/test/bytecode_1.4/test_single_stmt.pyc similarity index 100% rename from test/bytecode_1.4/test_single_stmt-1.4.pyc rename to test/bytecode_1.4/test_single_stmt.pyc diff --git a/test/bytecode_1.5/exec.pyc b/test/bytecode_1.5/exec.pyc deleted file mode 100644 index d1a50e6bdea0a398940ad799ddb943e85aa5cee1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 176 zcmbQ~$IB%#)!!xS+Ah7m=P#o&j~S&hl!h!j}ZV5t{wvb diff --git a/test/simple_source/bug14/01_print.py b/test/simple_source/bug14/01_print.py new file mode 100644 index 00000000..dae12a98 --- /dev/null +++ b/test/simple_source/bug14/01_print.py @@ -0,0 +1,5 @@ +# Python 1.4 aifc.py +def _readmark(self, markers): + if self._markers: print 'marker', + else: print 'markers', + print 'instead of', markers diff --git a/test/stdlib/compile-file.py b/test/stdlib/compile-file.py index 93b37688..cfbb9c5c 100755 --- a/test/stdlib/compile-file.py +++ b/test/stdlib/compile-file.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +"""byte compiles a Python program after version 2.2 or so. Also see compile_file_1x.py""" import sys if len(sys.argv) != 2: print("Usage: compile-file.py *python-file*") diff --git a/test/stdlib/compile_file_1x.py b/test/stdlib/compile_file_1x.py new file mode 100755 index 00000000..3017b280 --- /dev/null +++ b/test/stdlib/compile_file_1x.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""byte compiles a Python 1.x program""" +import sys +if len(sys.argv) != 2: + print("Usage: compile-file.py *python-file*") + sys.exit(1) +source = sys.argv[1] + +# assert source.endswith('.py') +basename = source[:-3] + +# We do this crazy way to support Python 1.4 which +# doesn't support version_info. +PY_VERSION = sys.version[:3] + +bytecode = "%s-%s.pyc" % (basename, PY_VERSION) + +import py_compile +print("# compiling %s to %s" % (source, bytecode)) +py_compile.compile(source, bytecode) +# import os +# os.system("../bin/uncompyle6 %s" % bytecode) diff --git a/uncompyle6/parsers/parse14.py b/uncompyle6/parsers/parse14.py index d1c3fc62..10f74ff1 100644 --- a/uncompyle6/parsers/parse14.py +++ b/uncompyle6/parsers/parse14.py @@ -23,6 +23,8 @@ class Python14Parser(Python15Parser): jb_pop14 POP_BLOCK else_suitel COME_FROM + print_items_nl_stmt ::= expr PRINT_ITEM_CONT print_items_opt PRINT_NEWLINE_CONT + """ def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG): diff --git a/uncompyle6/scanners/scanner14.py b/uncompyle6/scanners/scanner14.py index 89db85f7..5e80cf4a 100644 --- a/uncompyle6/scanners/scanner14.py +++ b/uncompyle6/scanners/scanner14.py @@ -32,5 +32,5 @@ class Scanner14(scan.Scanner15): # # for t in tokens: # # print(t) - - return tokens, customize + # + # return tokens, customize