Skip to main content

Python cross-version byte-code disassembler and marshal routines

Project description

buildstatus Latest Version Supported Python Versions

xdis

Cross-Python bytecode Disassembler and Marshal routines

Introduction

The Python dis module allows you to disassemble bytecode from the same version of Python that you are running on. But what about bytecode from different versions?

That’s what this package is for. It can “marshal load” Python bytecodes from different versions of Python. The command-line routine pydisasm will show disassembly output using Python 3.6 disassembly conventions.

Also, if you need to modify and write bytecode, the routines here can be of help. There are routines to pack and unpack the read-only tuples in Python’s Code type. For interoperability between Python 2 and 3 we provide our own versions of the Code type, and we provide routines to reduce the tedium in writing a bytecode file.

This package also has an extensive knowledge of Python bytecode magic numbers, including Pypy and others, and how to translate from sys.sys_info major, minor, and release numbers to the corresponding magic value.

So If you want to write a cross-version assembler, or a bytecode-level optimizer this package may also be useful. In addition to the kinds of instruction categorization that dis offers, we have additional categories for things that would be useful in such a bytecode optimizer.

The programs here accept bytecodes from Python version 1.3 to 3.7 or so. The code requires Python 2.4 or later and has been tested on Python running lots of Python versions.

To install versions for Python before 2.6 install via eggs or use the python-2.4 branch of git in github.

Installation

This uses setup.py, so it follows the standard Python routine:

pip install -r requirements.txt
pip install -r requirements-dev.txt
python setup.py install # may need sudo
# or if you have pyenv:
python setup.py develop

A GNU makefile is also provided so make install (possibly as root or sudo) will do the steps above.

Testing

make check

A GNU makefile has been added to smooth over setting running the right command, and running tests from fastest to slowest.

If you have remake installed, you can see the list of all tasks including tests via remake --tasks.

Usage

Run

./bin/pydisasm -h

for usage help.

As a drop-in replacement for dis

xdis also provides some support as a drop in replacement for the the Python library dis module. This is may be desirable when you want to use the improved API from Python 3.4 or later from an earlier Python version.

For example:

>>> # works in Python 2 and 3
>>> import xdis.std as dis
>>> [x.opname for x in dis.Bytecode('a = 10')]
['LOAD_CONST', 'STORE_NAME', 'LOAD_CONST', 'RETURN_VALUE']

There may some small differences in output produced for formatted disassembly or how we show compiler flags. We expect you’ll find the xdis output more informative though.

See Also

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xdis-3.8.10.tar.gz (182.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xdis-3.8.10-py35-none-any.whl (94.1 kB view details)

Uploaded Python 3.5

xdis-3.8.10-py34-none-any.whl (94.1 kB view details)

Uploaded Python 3.4

xdis-3.8.10-py33-none-any.whl (89.7 kB view details)

Uploaded Python 3.3

xdis-3.8.10-py27-none-any.whl (87.1 kB view details)

Uploaded Python 2.7

xdis-3.8.10-py3.5.egg (175.6 kB view details)

Uploaded Egg

xdis-3.8.10-py3.4.egg (176.0 kB view details)

Uploaded Egg

xdis-3.8.10-py3.3.egg (176.7 kB view details)

Uploaded Egg

xdis-3.8.10-py2.7.egg (172.4 kB view details)

Uploaded Egg

xdis-3.8.10-py2.5.egg (182.5 kB view details)

Uploaded Egg

xdis-3.8.10-py2.4.egg (185.4 kB view details)

Uploaded Egg

File details

Details for the file xdis-3.8.10.tar.gz.

File metadata

  • Download URL: xdis-3.8.10.tar.gz
  • Upload date:
  • Size: 182.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10.tar.gz
Algorithm Hash digest
SHA256 b00f37296edf2a4fe7b67b5d861c342426d442666d241674fdfc333936bd59bf
MD5 9d29f1367d2dcda2feebdb90032578b6
BLAKE2b-256 0ef91b1c45276a0a975991fcc97e0b727507868cb2e93f89c4a6349f1419c7ca

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py35-none-any.whl.

File metadata

  • Download URL: xdis-3.8.10-py35-none-any.whl
  • Upload date:
  • Size: 94.1 kB
  • Tags: Python 3.5
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py35-none-any.whl
Algorithm Hash digest
SHA256 a9a1b4905791c63c398bf80ced284f7aacee4bb53c42ce015e033965975f6eb6
MD5 74bc28fbda4d43f7cdc39c3bae852031
BLAKE2b-256 b535c2dd08318e4f5f2f26e465307c307ee0b1b857724c2f184c29009339390d

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py34-none-any.whl.

File metadata

  • Download URL: xdis-3.8.10-py34-none-any.whl
  • Upload date:
  • Size: 94.1 kB
  • Tags: Python 3.4
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py34-none-any.whl
Algorithm Hash digest
SHA256 3b4b034abb3d860ab8ca88a17b823e37b471fd7956d6a2cfbff8000ada3c99c8
MD5 ab627761f5dbff747ad5bea1808c821c
BLAKE2b-256 cf10423d3768976cd2bb5fb8a38094646f292334ece68262c65ec017ad955835

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py33-none-any.whl.

File metadata

  • Download URL: xdis-3.8.10-py33-none-any.whl
  • Upload date:
  • Size: 89.7 kB
  • Tags: Python 3.3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py33-none-any.whl
Algorithm Hash digest
SHA256 77e2e9460f5c03fd6136d8f607233cf9ab120875454772014815f9977a8e0d4f
MD5 d579258c28176681466d2043903e83aa
BLAKE2b-256 a40c301b6b7ff907f1819a1d8c1223401aa4c9efe8952c0f27d2160ea43c1aee

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py27-none-any.whl.

File metadata

  • Download URL: xdis-3.8.10-py27-none-any.whl
  • Upload date:
  • Size: 87.1 kB
  • Tags: Python 2.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py27-none-any.whl
Algorithm Hash digest
SHA256 dd35b3890313365f9429b9b3082006074b64bd6276840703a5484dab11617d68
MD5 3a6115ed1b46996857fb2c35e728c06e
BLAKE2b-256 f6f0ae00b838dd6c4b57a3124f9c864d7643042280bd6a316ec1488bdf8f0ce4

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py3.5.egg.

File metadata

  • Download URL: xdis-3.8.10-py3.5.egg
  • Upload date:
  • Size: 175.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py3.5.egg
Algorithm Hash digest
SHA256 af47896eab91eeb3fea1376d9685c293a6770668d605e7f1df775ee055735d4f
MD5 77669902953b2b795a7038c1dfe6b2b1
BLAKE2b-256 a0933f9e24ea0913c609b3666e3e8f034a1037036e24191679e8644cbad9ab43

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py3.4.egg.

File metadata

  • Download URL: xdis-3.8.10-py3.4.egg
  • Upload date:
  • Size: 176.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py3.4.egg
Algorithm Hash digest
SHA256 cbdd07d5217fbea1e06b21cf440a31cb51c520751dee9c54dcf3829ac83f577a
MD5 59206cf0aec88f6fb1063764ecd5e851
BLAKE2b-256 34d57aba0e23045b385971e03214cfb32de6870df4f923ceadd08881866d2410

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py3.3.egg.

File metadata

  • Download URL: xdis-3.8.10-py3.3.egg
  • Upload date:
  • Size: 176.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py3.3.egg
Algorithm Hash digest
SHA256 2ef6804390305e5ce92f265f5443e3bafb829615b3d419f84625263a93109d28
MD5 c4dec1b0a39a07b7c77d21befc8578e9
BLAKE2b-256 420cde3762542b9e52589a954b0cced546a433e6fea35b210c4c89e880315ca1

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py2.7.egg.

File metadata

  • Download URL: xdis-3.8.10-py2.7.egg
  • Upload date:
  • Size: 172.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py2.7.egg
Algorithm Hash digest
SHA256 b466345a773e8a51fbd7fbe01ba31d74c47bf826c8f8aa3e4c4307d6921dcd44
MD5 f6974c8ea4ca5b6e9bb39c736ec98552
BLAKE2b-256 0c265aae73f5569df64d8b9d22020d58c7a87bb0287e9e605c808683da91e898

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py2.5.egg.

File metadata

  • Download URL: xdis-3.8.10-py2.5.egg
  • Upload date:
  • Size: 182.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py2.5.egg
Algorithm Hash digest
SHA256 e17819903dbb8ec8f3b7e85ff71f6343de4b81b7b9fbe3f7d1c6e352bc5d360c
MD5 a415aea8c47b003028c7659099169766
BLAKE2b-256 c4271385be8f2e1cbc86619d259ce5802b525deec2c9cd76d9c9af49a8324791

See more details on using hashes here.

File details

Details for the file xdis-3.8.10-py2.4.egg.

File metadata

  • Download URL: xdis-3.8.10-py2.4.egg
  • Upload date:
  • Size: 185.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for xdis-3.8.10-py2.4.egg
Algorithm Hash digest
SHA256 3395cb7f28dca29c8bc0d0c62d69f174c1e6156eea343396652c7223d3925e1c
MD5 d6761d2e9a794a7ab27f062581b122e5
BLAKE2b-256 76053603380e27a52979b77a015ee3ab107bee72bb7568ed45eb2a225cd19541

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page