diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2020-12-21 07:15:11 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-01-10 08:06:26 -0500 |
commit | 8cd9b07dda3f7eb85676d18c6a87d0b787fdd701 (patch) | |
tree | 5ea7104468bafa0c710a60309c34fb20b469683a | |
parent | a1a27826771d454c5949a933c4edfe918ff455f3 (diff) | |
download | python-coveragepy-git-8cd9b07dda3f7eb85676d18c6a87d0b787fdd701.tar.gz |
show_pyc: Flags changed in 3.9
-rw-r--r-- | lab/show_pyc.py | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/lab/show_pyc.py b/lab/show_pyc.py index 7573c1c3..b4dc7cd7 100644 --- a/lab/show_pyc.py +++ b/lab/show_pyc.py @@ -1,6 +1,14 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt +""" +Dump the contents of a .pyc file. + +The output will only be correct if run with the same version of Python that +produced the .pyc. + +""" + import binascii import dis import marshal @@ -55,15 +63,31 @@ CO_FLAGS = [ ('CO_ITERABLE_COROUTINE', 0x00100), ('CO_ASYNC_GENERATOR', 0x00200), ('CO_GENERATOR_ALLOWED', 0x01000), - ('CO_FUTURE_DIVISION', 0x02000), - ('CO_FUTURE_ABSOLUTE_IMPORT', 0x04000), - ('CO_FUTURE_WITH_STATEMENT', 0x08000), - ('CO_FUTURE_PRINT_FUNCTION', 0x10000), - ('CO_FUTURE_UNICODE_LITERALS', 0x20000), - ('CO_FUTURE_BARRY_AS_BDFL', 0x40000), - ('CO_FUTURE_GENERATOR_STOP', 0x80000), ] +if sys.version_info < (3, 9): + CO_FLAGS += [ + ('CO_FUTURE_DIVISION', 0x02000), + ('CO_FUTURE_ABSOLUTE_IMPORT', 0x04000), + ('CO_FUTURE_WITH_STATEMENT', 0x08000), + ('CO_FUTURE_PRINT_FUNCTION', 0x10000), + ('CO_FUTURE_UNICODE_LITERALS', 0x20000), + ('CO_FUTURE_BARRY_AS_BDFL', 0x40000), + ('CO_FUTURE_GENERATOR_STOP', 0x80000), + ] +else: + CO_FLAGS += [ + ('CO_FUTURE_DIVISION', 0x0020000), + ('CO_FUTURE_ABSOLUTE_IMPORT', 0x0040000), + ('CO_FUTURE_WITH_STATEMENT', 0x0080000), + ('CO_FUTURE_PRINT_FUNCTION', 0x0100000), + ('CO_FUTURE_UNICODE_LITERALS', 0x0200000), + ('CO_FUTURE_BARRY_AS_BDFL', 0x0400000), + ('CO_FUTURE_GENERATOR_STOP', 0x0800000), + ('CO_FUTURE_ANNOTATIONS', 0x1000000), + ] + + def show_code(code, indent='', number=None): label = "" if number is not None: |