From c4252a534dcf748013e9375244cda7fb14ab61f6 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 26 Apr 2020 21:41:38 -0400 Subject: [PATCH] Get ready for release 1.1.0 --- ChangeLog | 48 ++++++++++++- NEWS.md | 8 ++- __pkginfo__.py | 2 +- admin-tools/pyenv-versions | 2 +- pytest/test_write_pyc.py | 12 ++-- test/gcd-3.7.pyasm | 141 ------------------------------------ test/gcd-3.8.pyasm | 143 ------------------------------------- xasm/version.py | 2 +- xasm/xasm_cli.py | 4 +- 9 files changed, 66 insertions(+), 296 deletions(-) delete mode 100644 test/gcd-3.7.pyasm delete mode 100644 test/gcd-3.8.pyasm diff --git a/ChangeLog b/ChangeLog index 2bbdb5a..3da87c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,50 @@ +2020-04-26 rocky + + * ChangeLog, __pkginfo__.py, xasm/version.py: Get ready for release + 1.1.0 + +2020-04-24 rocky + + * __pkginfo__.py, pytest/test_write_pyc.py, test/gcd-3.7.pyasm, + test/gcd-3.8.pyasm, xasm/write_pyc.py: Add 3.7 PEP 552 header for + 3.7+ Fixes #3 Bump xdis version + +2020-04-18 R. Bernstein + + * .github/FUNDING.yml: Create FUNDING.yml + +2020-04-17 rocky + + * test/comp.py, xasm/assemble.py, xasm/write_pyc.py: Misc assembly + bug fixes: * Add 3.8+ posonlyargcount * More sensitive to writing pep pep552 bits and network order of + ints * note positional arguments in 3.6+ + +2020-04-17 rocky + + * xasm/assemble.py: Track xdis changes to Code repr() + +2020-04-17 rocky + + * Makefile, __pkginfo__.py, admin-tools/how-to-make-a-release.md, + admin-tools/pyenv-versions, pytest/.gitignore, + pytest/test_write_pyc.py, test/test_all.py, xasm/.gitignore, + xasm/assemble.py, xasm/misc.py, xasm/write_pyc.py, xasm/xasm_cli.py: + Revise for new xdis. Add Better write_pyc() fn + +2019-11-06 rocky + + * xasm/assemble.py: Ensure bytecode is in range + +2019-10-19 rocky + + * xasm/assemble.py: Add an "assert" message + 2019-10-19 rocky - * MANIFEST.in, NEWS.md, README.rst, admin-tools/check-versions.sh, - admin-tools/make-dist.sh, admin-tools/pyenv-versions, - xasm/version.py: Get ready for release 1.0.0 + * ChangeLog, MANIFEST.in, Makefile, NEWS.md, README.rst, + __pkginfo__.py, admin-tools/check-versions.sh, + admin-tools/make-dist.sh, admin-tools/pyenv-versions, setup.py, + xasm/version.py: Release 1.0.0 2019-10-19 rocky diff --git a/NEWS.md b/NEWS.md index 43c5030..90f9ded 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ +1.1.0 2019-10-19 + +- Fix bugs in writing 3.7 and 3.8 pyc +- Require newer xdis to get fixes to 3.8 pyc marshaling + + 1.0.0 2019-10-19 - Go over docs. - Require newer xdis to get early bytecodes bytecodes: 1.0, 1.1, 1.2, and 1.6. -- +- More sensitive to network ordering diff --git a/__pkginfo__.py b/__pkginfo__.py index ac21600..ed2e9f2 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -39,7 +39,7 @@ mailing_list = "python-debugger@googlegroups.com" modname = "xasm" py_modules = None -setup_requires = ["pytest-runner", "xdis >= 4.5.0, < 4.6.0"] +setup_requires = ["pytest-runner", "xdis >= 4.5.1, < 4.6.0"] # scripts = ['bin/pydisasm'] short_desc = "Python cross-version byte-code assembler" tests_require = ["pytest", _six] diff --git a/admin-tools/pyenv-versions b/admin-tools/pyenv-versions index 30f1e3d..88bc4a7 100644 --- a/admin-tools/pyenv-versions +++ b/admin-tools/pyenv-versions @@ -5,4 +5,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then echo "This script should be *sourced* rather than run directly through bash" exit 1 fi -export PYVERSIONS='3.6.9 3.7.7 3.3.7 2.7.17 3.4.10 3.5.9 3.8.2' +export PYVERSIONS='3.6.10 3.7.7 3.3.7 2.7.18 3.4.10 3.5.9 3.8.2' diff --git a/pytest/test_write_pyc.py b/pytest/test_write_pyc.py index bd75768..ebfb1e1 100644 --- a/pytest/test_write_pyc.py +++ b/pytest/test_write_pyc.py @@ -1,7 +1,7 @@ import os import os.path as osp from tempfile import NamedTemporaryFile -from xdis import load_module +from xdis import load_module, PYTHON3 from xasm.write_pyc import write_pycfile def get_srcdir(): @@ -12,14 +12,18 @@ def get_srcdir(): os.chdir(src_dir) -def test_roundtrip(): +def test_roundtrip3(): + if not PYTHON3: + print("test skipped because Python 2.x has problems creating Python 3.x files") + return fp = NamedTemporaryFile(mode="wb+", suffix=".pyc", prefix="test_pyc-", delete=False) orig_path="testdata/test_pyc.pyc" version, timestamp, magic_int, co, is_pypy, source_size, sip_hash = load_module(orig_path) write_pycfile(fp, [co], timestamp, version) new_path = fp.name + size = fp.tell() fp.close() - print("Wrote Python %s bytecode file %s" % (version, fp.name)) + print("Wrote Python %s bytecode file %s; %d bytes" % (version, fp.name, size)) old_fp = open(orig_path, "rb") new_fp = open(new_path, "rb") compare_size=590 @@ -27,4 +31,4 @@ def test_roundtrip(): os.unlink(new_path) if __name__ == "__main__": - test_roundtrip() + test_roundtrip3() diff --git a/test/gcd-3.7.pyasm b/test/gcd-3.7.pyasm deleted file mode 100644 index 54bcb08..0000000 --- a/test/gcd-3.7.pyasm +++ /dev/null @@ -1,141 +0,0 @@ -# pydisasm version 4.5.0 -# Python bytecode 3.7 (3394) -# Disassembled from Python 3.7.7 (default, Mar 16 2020, 13:12:47) -# [GCC 9.2.1 20191008] -# Timestamp in code: 1499156389 (2017-07-04 04:19:49) -# Source code size mod 2**32: 577 bytes - -# Method Name: gcd -# Filename: gcd.py -# Argument count: 2 -# Keyword-only arguments: 0 -# Number of locals: 2 -# Stack size: 3 -# Flags: 0x00000043 (NOFREE | NEWLOCALS | OPTIMIZED) -# First Line: 11 -# Constants: -# 0: ' GCD. We assume positive numbers' -# 1: 0 -# 2: None -# 3: 1 -# Names: -# 0: gcd -# Varnames: -# a, b -# Positional arguments: -# a, b - 15: - LOAD_FAST (a) - LOAD_FAST (b) - COMPARE_OP (>) - POP_JUMP_IF_FALSE L18 (to 18) - - 16: - LOAD_FAST (b) - LOAD_FAST (a) - ROT_TWO - STORE_FAST (a) - STORE_FAST (b) - -L18: - 19: - LOAD_FAST (a) - LOAD_CONST (0) - COMPARE_OP (<=) - POP_JUMP_IF_FALSE L30 (to 30) - - 20: - LOAD_CONST (None) - RETURN_VALUE - -L30: - 21: - LOAD_FAST (a) - LOAD_CONST (1) - COMPARE_OP (==) - POP_JUMP_IF_TRUE L46 (to 46) - LOAD_FAST (a) - LOAD_FAST (b) - COMPARE_OP (==) - POP_JUMP_IF_FALSE L50 (to 50) - -L46: - 22: - LOAD_FAST (a) - RETURN_VALUE - -L50: - 23: - LOAD_GLOBAL (gcd) - LOAD_FAST (b) - LOAD_FAST (a) - BINARY_SUBTRACT - LOAD_FAST (a) - CALL_FUNCTION 2 - RETURN_VALUE - - -# Method Name: -# Filename: gcd.py -# Argument count: 0 -# Keyword-only arguments: 0 -# Number of locals: 0 -# Stack size: 7 -# Flags: 0x00000040 (NOFREE) -# First Line: 10 -# Constants: -# 0: "Greatest Common Divisor\n\nSome characterstics of this program used for testing check_args() does\nnot have a 'return' statement.\n\ncheck_args() raises an uncaught exception when given the wrong number\nof parameters.\n\n" -# 1: , line 11 -# 2: 'gcd' -# 3: '__main__' -# 4: (3, 5) -# 5: 'The GCD of %d and %d is %d' -# 6: None -# Names: -# 0: __doc__ -# 1: gcd -# 2: __name__ -# 3: a -# 4: b -# 5: print - 10: - LOAD_CONST 0 ("Greatest Common Divisor\n\nSome characterstics of this program used for testing check_args() does\nnot have a 'return' statement.\n\ncheck_args() raises an uncaught exception when given the wrong number\nof parameters.\n\n") - STORE_NAME (__doc__) - - 11: - LOAD_CONST 1 (, line 11) - LOAD_CONST ('gcd') - MAKE_FUNCTION 0 - STORE_NAME (gcd) - - 25: - LOAD_NAME (__name__) - LOAD_CONST ('__main__') - COMPARE_OP (==) - POP_JUMP_IF_FALSE L52 (to 52) - - 26: - LOAD_CONST 4 ((3, 5)) - UNPACK_SEQUENCE 2 - STORE_NAME (a) - STORE_NAME (b) - - 27: - LOAD_NAME (print) - LOAD_CONST 5 ('The GCD of %d and %d is %d') - LOAD_NAME (a) - LOAD_NAME (b) - LOAD_NAME (gcd) - LOAD_NAME (a) - LOAD_NAME (b) - CALL_FUNCTION 2 - BUILD_TUPLE 3 - BINARY_MODULO - CALL_FUNCTION 1 - POP_TOP - -L52: - 28: - LOAD_CONST (None) - RETURN_VALUE - diff --git a/test/gcd-3.8.pyasm b/test/gcd-3.8.pyasm deleted file mode 100644 index 48707e2..0000000 --- a/test/gcd-3.8.pyasm +++ /dev/null @@ -1,143 +0,0 @@ -# pydisasm version 4.5.0 -# Python bytecode 3.8 (3413) -# Disassembled from Python 3.8.2 (default, Mar 6 2020, 19:12:28) -# [GCC 9.2.1 20191008] -# Timestamp in code: 1499156389 (2017-07-04 04:19:49) -# Source code size mod 2**32: 577 bytes - -# Method Name: gcd -# Filename: gcd.py -# Argument count: 2 -# Position-only argument count: 0 -# Keyword-only arguments: 0 -# Number of locals: 2 -# Stack size: 3 -# Flags: 0x00000043 (NOFREE | NEWLOCALS | OPTIMIZED) -# First Line: 11 -# Constants: -# 0: ' GCD. We assume positive numbers' -# 1: 0 -# 2: None -# 3: 1 -# Names: -# 0: gcd -# Varnames: -# a, b -# Positional arguments: -# a, b - 15: - LOAD_FAST (a) - LOAD_FAST (b) - COMPARE_OP (>) - POP_JUMP_IF_FALSE L18 (to 18) - - 16: - LOAD_FAST (b) - LOAD_FAST (a) - ROT_TWO - STORE_FAST (a) - STORE_FAST (b) - -L18: - 19: - LOAD_FAST (a) - LOAD_CONST (0) - COMPARE_OP (<=) - POP_JUMP_IF_FALSE L30 (to 30) - - 20: - LOAD_CONST (None) - RETURN_VALUE - -L30: - 21: - LOAD_FAST (a) - LOAD_CONST (1) - COMPARE_OP (==) - POP_JUMP_IF_TRUE L46 (to 46) - LOAD_FAST (a) - LOAD_FAST (b) - COMPARE_OP (==) - POP_JUMP_IF_FALSE L50 (to 50) - -L46: - 22: - LOAD_FAST (a) - RETURN_VALUE - -L50: - 23: - LOAD_GLOBAL (gcd) - LOAD_FAST (b) - LOAD_FAST (a) - BINARY_SUBTRACT - LOAD_FAST (a) - CALL_FUNCTION 2 - RETURN_VALUE - - -# Method Name: -# Filename: gcd.py -# Argument count: 0 -# Position-only argument count: 0 -# Keyword-only arguments: 0 -# Number of locals: 0 -# Stack size: 7 -# Flags: 0x00000040 (NOFREE) -# First Line: 2 -# Constants: -# 0: "Greatest Common Divisor\n\nSome characterstics of this program used for testing check_args() does\nnot have a 'return' statement.\n\ncheck_args() raises an uncaught exception when given the wrong number\nof parameters.\n\n" -# 1: , line 11 -# 2: 'gcd' -# 3: '__main__' -# 4: (3, 5) -# 5: 'The GCD of %d and %d is %d' -# 6: None -# Names: -# 0: __doc__ -# 1: gcd -# 2: __name__ -# 3: a -# 4: b -# 5: print - 2: - LOAD_CONST 0 ("Greatest Common Divisor\n\nSome characterstics of this program used for testing check_args() does\nnot have a 'return' statement.\n\ncheck_args() raises an uncaught exception when given the wrong number\nof parameters.\n\n") - STORE_NAME (__doc__) - - 11: - LOAD_CONST 1 (, line 11) - LOAD_CONST ('gcd') - MAKE_FUNCTION 0 - STORE_NAME (gcd) - - 25: - LOAD_NAME (__name__) - LOAD_CONST ('__main__') - COMPARE_OP (==) - POP_JUMP_IF_FALSE L52 (to 52) - - 26: - LOAD_CONST 4 ((3, 5)) - UNPACK_SEQUENCE 2 - STORE_NAME (a) - STORE_NAME (b) - - 27: - LOAD_NAME (print) - LOAD_CONST 5 ('The GCD of %d and %d is %d') - LOAD_NAME (a) - LOAD_NAME (b) - LOAD_NAME (gcd) - LOAD_NAME (a) - LOAD_NAME (b) - CALL_FUNCTION 2 - BUILD_TUPLE 3 - BINARY_MODULO - CALL_FUNCTION 1 - POP_TOP - -L52: - 28: - LOAD_CONST (None) - RETURN_VALUE - diff --git a/xasm/version.py b/xasm/version.py index bad289c..0ff3bc5 100644 --- a/xasm/version.py +++ b/xasm/version.py @@ -1,3 +1,3 @@ # This file is suitable for sourcing inside bash as # well as importing into Python -VERSION='1.0.0' +VERSION='1.1.0' diff --git a/xasm/xasm_cli.py b/xasm/xasm_cli.py index 8e36b93..01f983c 100755 --- a/xasm/xasm_cli.py +++ b/xasm/xasm_cli.py @@ -37,7 +37,9 @@ def main(pyc_file, asm_path): with open(pyc_file, file_mode) as fp: write_pycfile(fp, asm.code_list, asm.timestamp, float(asm.python_version)) - print("Wrote Python %s bytecode file %s" % (asm.python_version, pyc_file)) + size = fp.tell() + print("Wrote Python %s bytecode file %s; %d bytes." % + (asm.python_version, pyc_file, size)) if __name__ == '__main__': main(sys.argv[1:])