Hello community, here is the log from the commit of package python-xdis for openSUSE:Factory checked in at 2020-04-16 23:03:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-xdis (Old) and /work/SRC/openSUSE:Factory/.python-xdis.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xdis" Thu Apr 16 23:03:18 2020 rev:9 rq:794470 version:4.2.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-xdis/python-xdis.changes 2020-03-24 22:39:08.485287667 +0100 +++ /work/SRC/openSUSE:Factory/.python-xdis.new.2738/python-xdis.changes 2020-04-16 23:03:24.595683129 +0200 @@ -1,0 +2,6 @@ +Thu Apr 16 07:33:45 UTC 2020 - Tomáš Chvátal <[email protected]> + +- Update to 4.2.4: + * Add Instruction instance methods: #Instruction.is_jump() and #Instruction.jumps_forward() + +------------------------------------------------------------------- Old: ---- 4.2.3.tar.gz New: ---- 4.2.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-xdis.spec ++++++ --- /var/tmp/diff_new_pack.GaFVg4/_old 2020-04-16 23:03:25.595684019 +0200 +++ /var/tmp/diff_new_pack.GaFVg4/_new 2020-04-16 23:03:25.599684022 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-xdis -Version: 4.2.3 +Version: 4.2.4 Release: 0 Summary: Python cross-version byte-code disassembler and marshal routines License: GPL-2.0-only ++++++ 4.2.3.tar.gz -> 4.2.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/NEWS.md new/python-xdis-4.2.4/NEWS.md --- old/python-xdis-4.2.3/NEWS.md 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/NEWS.md 2020-03-25 00:10:39.000000000 +0100 @@ -1,8 +1,14 @@ +4.2.4 2020-03-24 COVID-19 time +============================== + +- Add Instruction instance methods + #Instruction.is_jump() and #Instruction.jumps_forward() + 4.2.3 2020-03-16 post ides-of-march =================================== * Add Python versions: 3.7.7, 3.8.2, and 3.9.0alpha1, -* Create a class for "STORE" instructions +* Create a set for "STORE" instructions * facilitate code type freezing (PR #57) * Warn about cross-decompilation problems for byte types diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/admin-tools/how-to-make-a-release.md new/python-xdis-4.2.4/admin-tools/how-to-make-a-release.md --- old/python-xdis-4.2.3/admin-tools/how-to-make-a-release.md 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/admin-tools/how-to-make-a-release.md 2020-03-25 00:10:39.000000000 +0100 @@ -69,7 +69,7 @@ $ . ./admin-tools/make-dist-newer.sh $ twine check dist/xdis-$VERSION* -Goto https://github.com/rocky/python-xdis/releases +Goto https://github.com/rocky/python-xdis/releases/new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/pytest/Makefile new/python-xdis-4.2.4/pytest/Makefile --- old/python-xdis-4.2.3/pytest/Makefile 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/pytest/Makefile 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -PHONY=check test pytest - -PYTHON ?= python - -#: Run all tests -test check pytest: - py.test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/pytest/test_instructions.py new/python-xdis-4.2.4/pytest/test_instructions.py --- old/python-xdis-4.2.3/pytest/test_instructions.py 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/pytest/test_instructions.py 2020-03-25 00:10:39.000000000 +0100 @@ -9,6 +9,13 @@ return 0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0 return 3 +# Bytecode that has a single conditional jump forward and an unconditional jump backwards +def loop(): + x = False + while x: + x = True + return x + from xdis.bytecode import Bytecode pytest.mark.skipif(sys.version_info == (3,6), @@ -33,3 +40,29 @@ # print(inst) else: assert True + +pytest.mark.skipif(sys.version_info < (2,7), + reason="asssume Python 2.7 or greater") +def test_inst_jumps(): + if (sys.version_info >= (2,7)): + variant = 'pypy' if IS_PYPY else None + opc = get_opcode_module(sys.version_info, variant) + bytecode_obj = Bytecode(extended_arg_fn36, opc) + instructions = list(bytecode_obj.get_instructions(loop)) + seen_pjif = False + seen_ja = False + for inst in instructions: + if inst.opname == "POP_JUMP_IF_FALSE": + assert inst.is_jump() + seen_pjif = True + elif inst.opname == "JUMP_ABSOLUTE": + assert inst.is_jump() + assert not inst.jumps_forward() + seen_ja = True + pass + pass + assert seen_pjif + assert seen_ja + +if __name__ == '__main__': + test_inst_jumps() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/xdis/Makefile new/python-xdis-4.2.4/xdis/Makefile --- old/python-xdis-4.2.3/xdis/Makefile 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/xdis/Makefile 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -# Whatever it is you want to do, it should be forwarded to the -# to top-level irectories -PHONY=check all -all: check - -%: - $(MAKE) -C .. $@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/xdis/bytecode.py new/python-xdis-4.2.4/xdis/bytecode.py --- old/python-xdis-4.2.3/xdis/bytecode.py 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/xdis/bytecode.py 2020-03-25 00:10:39.000000000 +0100 @@ -460,6 +460,21 @@ pass return ' '.join(fields).rstrip() + def is_jump(self): + """ + Return True if instruction is some sort of jump. + """ + return self.optype in ("jabs", "jrel") + + def jumps_forward(self): + """ + Return True if instruction is jump backwards + """ + return ( + self.is_jump() + and self.offset < self.argval + ) + # FIXME: figure out how to do disassemble passing in opnames class Bytecode(object): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/xdis/opcodes/Makefile new/python-xdis-4.2.4/xdis/opcodes/Makefile --- old/python-xdis-4.2.3/xdis/opcodes/Makefile 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/xdis/opcodes/Makefile 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -# Whatever it is you want to do, it should be forwarded to the -# to top-level irectories -PHONY=check all -all: check - -%: - $(MAKE) -C ../.. $@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/xdis/util.py new/python-xdis-4.2.4/xdis/util.py --- old/python-xdis-4.2.3/xdis/util.py 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/xdis/util.py 2020-03-25 00:10:39.000000000 +0100 @@ -16,6 +16,7 @@ from math import copysign + def code2num(code, i): if isinstance(code, str): return ord(code[i]) @@ -43,7 +44,6 @@ 0x00000100: "ITERABLE_COROUTINE", # These are in Python 3.6+ 0x00000200: "ASYNC_GENERATOR", - # These are used only in Python 2.x */ 0x00001000: "GENERATOR_ALLOWED", 0x00002000: "FUTURE_DIVISION", @@ -89,6 +89,15 @@ names.reverse() return "%s (%s)" % (result, " | ".join(names)) +def co_flags_is_async(co_flags): + """ + Return True iff co_flags indicates an async function. + """ + return co_flags & ( + COMPILER_FLAG_BIT["COROUTINE"] + | COMPILER_FLAG_BIT["ITERABLE_COROUTINE"] + | COMPILER_FLAG_BIT["ASYNC_GENERATOR"] + ) def code_has_star_arg(code): """Return True iff @@ -101,10 +110,12 @@ The code object has a variable keyword parameter (**kwargs-like).""" return (code.co_flags & 8) != 0 + def is_negative_zero(n): """Returns true if n is -0.0""" return n == 0.0 and copysign(1, n) == -1 + def better_repr(v): """Work around Python's unorthogonal and unhelpful repr() for primitive float and complex.""" @@ -139,6 +150,7 @@ else: return repr(v) + def format_code_info(co, version, name=None, is_pypy=False): if not name: name = co.co_name @@ -159,7 +171,9 @@ lines.append("# Stack size: %s" % co.co_stacksize) if version >= 1.3: - lines.append("# Flags: %s" % pretty_flags(co.co_flags, is_pypy=is_pypy)) + lines.append( + "# Flags: %s" % pretty_flags(co.co_flags, is_pypy=is_pypy) + ) if version >= 1.5: lines.append("# First Line: %s" % co.co_firstlineno) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-xdis-4.2.3/xdis/version.py new/python-xdis-4.2.4/xdis/version.py --- old/python-xdis-4.2.3/xdis/version.py 2020-03-16 19:28:04.000000000 +0100 +++ new/python-xdis-4.2.4/xdis/version.py 2020-03-25 00:10:39.000000000 +0100 @@ -1,3 +1,3 @@ # This file is suitable for sourcing inside bash as # well as importing into Python -VERSION='4.2.3' +VERSION='4.2.4'
