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, Bytecode, and Magic Number Manipulation package

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

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-4.0.3.tar.gz (185.9 kB view details)

Uploaded Source

Built Distributions

xdis-4.0.3-py37-none-any.whl (94.8 kB view details)

Uploaded Python 3.7

xdis-4.0.3-py36-none-any.whl (94.8 kB view details)

Uploaded Python 3.6

xdis-4.0.3-py35-none-any.whl (94.8 kB view details)

Uploaded Python 3.5

xdis-4.0.3-py34-none-any.whl (94.9 kB view details)

Uploaded Python 3.4

xdis-4.0.3-py33-none-any.whl (90.6 kB view details)

Uploaded Python 3.3

xdis-4.0.3-py27-none-any.whl (94.8 kB view details)

Uploaded Python 2.7

xdis-4.0.3-py26-none-any.whl (90.6 kB view details)

Uploaded Python 2.6

File details

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

File metadata

  • Download URL: xdis-4.0.3.tar.gz
  • Upload date:
  • Size: 185.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3.tar.gz
Algorithm Hash digest
SHA256 60d2f5df8f0f81f466b21085624a88e0924e204b7ddeb4dfd0cb5225e0deda25
MD5 2217d15b4abb1a4b9898f8a1567f701d
BLAKE2b-256 da92faa9fbf8f1fe4eb2a0973b4ace550c0dc481bd5812a6788194e2c639ab71

See more details on using hashes here.

Provenance

File details

Details for the file xdis-4.0.3-py37-none-any.whl.

File metadata

  • Download URL: xdis-4.0.3-py37-none-any.whl
  • Upload date:
  • Size: 94.8 kB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py37-none-any.whl
Algorithm Hash digest
SHA256 ca98e63b86c938cf5d03b5ae2a4126faacaceecf08caf913808c0aeaeed7a6b1
MD5 79a1e5467e092cf278b4465d0633efb9
BLAKE2b-256 569f00d0a85a2cc64e22a291eb6a38ff9e40db4b2bf21bd84a539a8fe7fd3470

See more details on using hashes here.

Provenance

File details

Details for the file xdis-4.0.3-py36-none-any.whl.

File metadata

  • Download URL: xdis-4.0.3-py36-none-any.whl
  • Upload date:
  • Size: 94.8 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py36-none-any.whl
Algorithm Hash digest
SHA256 b1e40297e9aee734b116c6f6bdbdb585be14d3b3b078b857770966d6589f0910
MD5 eda1223c141a13f796d5bee4d09d892b
BLAKE2b-256 6b4bb227de7b45ccbbba9645cc3192fe704aead1923885aece380a5cfebd563d

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.3-py35-none-any.whl
  • Upload date:
  • Size: 94.8 kB
  • Tags: Python 3.5
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py35-none-any.whl
Algorithm Hash digest
SHA256 b9d699a8ae803ad33842edd9fe08cbffd93e818e0fab1201eb84d0362dfe8517
MD5 145c1213bcbdb013647b6ccf49536c50
BLAKE2b-256 5a9abc154cbf6ccfa1db22b09f1c73550c01c0f554665d9a986713c6daa09e59

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.3-py34-none-any.whl
  • Upload date:
  • Size: 94.9 kB
  • Tags: Python 3.4
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py34-none-any.whl
Algorithm Hash digest
SHA256 e44f2f3dea8d8a38eb4e1788f8ddb0b7aafc39c0dad5bbf20afdef4729d7ac06
MD5 ed218daa66948b326a124212bacdcb86
BLAKE2b-256 5e5a73c8f7fed18e455f0e490a2be8ad6e36a51ca905ba6a6983ba3dec6141a5

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.3-py33-none-any.whl
  • Upload date:
  • Size: 90.6 kB
  • Tags: Python 3.3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py33-none-any.whl
Algorithm Hash digest
SHA256 2276f3adf5db3ea17a9ad3159495f8c67cf8e8ec47d525d146f0ef086c5d48b4
MD5 b9b531708f735472a5eddb799c602c98
BLAKE2b-256 cd763b5a6ab6d41a4ef0efdfda143e36be7f4f59c661b27b7d7ad937067a4a7f

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.3-py27-none-any.whl
  • Upload date:
  • Size: 94.8 kB
  • Tags: Python 2.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py27-none-any.whl
Algorithm Hash digest
SHA256 923c03aa6d2afea386cb701b6270b7994769ba8ba164a16fa63dc9865199d35b
MD5 d0bb94a3e85b6f7da54b68df98bc7a34
BLAKE2b-256 5605192bfa6c10068a4d6cbed0d5d86f47e589d61783b2069c6321e7757043fe

See more details on using hashes here.

Provenance

File details

Details for the file xdis-4.0.3-py26-none-any.whl.

File metadata

  • Download URL: xdis-4.0.3-py26-none-any.whl
  • Upload date:
  • Size: 90.6 kB
  • Tags: Python 2.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for xdis-4.0.3-py26-none-any.whl
Algorithm Hash digest
SHA256 461aa48dc16ffd611838e8c9ff8748c472310b21eb7817ed9b17c542811b234e
MD5 1f199fb3d1483c04cd18612d0b4340f9
BLAKE2b-256 3fec93817e329da2ab64747d8cbd11505877e10e60bbfcbf4856e3163aa2d9d6

See more details on using hashes here.

Provenance

Supported by

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