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

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

Uploaded Source

Built Distributions

xdis-4.0.0-py36-none-any.whl (93.9 kB view details)

Uploaded Python 3.6

xdis-4.0.0-py35-none-any.whl (93.9 kB view details)

Uploaded Python 3.5

xdis-4.0.0-py34-none-any.whl (93.9 kB view details)

Uploaded Python 3.4

xdis-4.0.0-py33-none-any.whl (89.6 kB view details)

Uploaded Python 3.3

xdis-4.0.0-py27-none-any.whl (93.9 kB view details)

Uploaded Python 2.7

xdis-4.0.0-py3.7.egg (171.8 kB view details)

Uploaded Source

xdis-4.0.0-py3.6.egg (171.8 kB view details)

Uploaded Source

xdis-4.0.0-py3.5.egg (174.7 kB view details)

Uploaded Source

xdis-4.0.0-py3.4.egg (175.2 kB view details)

Uploaded Source

xdis-4.0.0-py3.3.egg (175.9 kB view details)

Uploaded Source

xdis-4.0.0-py2.7.egg (171.8 kB view details)

Uploaded Source

xdis-4.0.0-py2.5.egg (181.8 kB view details)

Uploaded Source

xdis-4.0.0-py2.4.egg (184.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: xdis-4.0.0.tar.gz
  • Upload date:
  • Size: 183.1 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0.tar.gz
Algorithm Hash digest
SHA256 d5aac3e08e85094f1d594bedb95ff5386db05d3a98109998033675ca1404b7f0
MD5 c1c08e20e26bff4dfbec0251a5843361
BLAKE2b-256 ff18a5e78123f88d7f339dfde5877e9d5d0043aaf0d41af764877ca880f3bfe8

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py36-none-any.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py36-none-any.whl
Algorithm Hash digest
SHA256 d38387951c73da3420ef278e9257f0630f66b63aadc7c4f3df82f2f5a13121de
MD5 63392f39e8b03916bd9bf40fa0481a27
BLAKE2b-256 efed636fdd814974abc4934118924361f878a6ad3d83505e3108a7cba338ad4d

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py35-none-any.whl
  • Upload date:
  • Size: 93.9 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py35-none-any.whl
Algorithm Hash digest
SHA256 3c26452316dc3ad9125cf9ae3eb359e3797baf32916a358033555e11ef676cfd
MD5 1f848c476f4382fde6bcb571bd399fbd
BLAKE2b-256 403ef1ec542270f27b11f0781ef5f06c2519668bc289f35d0a5189622814d3f7

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py34-none-any.whl
  • Upload date:
  • Size: 93.9 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py34-none-any.whl
Algorithm Hash digest
SHA256 82a1b9d1538e10801716f09e1ce37453319d50a19ee80d142c145bd9508c1644
MD5 4232f2df42a8c442021af84a01a86133
BLAKE2b-256 d5ec1874bca83037a20b645ab7672144fc3c1e6daf67e30c0135446e2e8199b8

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py33-none-any.whl
  • Upload date:
  • Size: 89.6 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py33-none-any.whl
Algorithm Hash digest
SHA256 7455c2f2511bc1a9453c7e2ac232a014c0ece5d74b741779ca3988392eea7997
MD5 8027b00b46752f481ebd9b47c067ab59
BLAKE2b-256 cf462fdb126ed8f15e33096a7a8f1661b53bbec9f2f2fb741f7a9d76d5a50d6b

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py27-none-any.whl
  • Upload date:
  • Size: 93.9 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py27-none-any.whl
Algorithm Hash digest
SHA256 e061d1d4dfb311fbb517b8e8de25d5b09f6d6650929ff348ea633af4423e3b29
MD5 aad2bceaeae42affc82145ec6ac36771
BLAKE2b-256 1ce8560d23438519e525b7233c2e9534a92ee58681fcb9abd484b2046b61593e

See more details on using hashes here.

Provenance

File details

Details for the file xdis-4.0.0-py3.7.egg.

File metadata

  • Download URL: xdis-4.0.0-py3.7.egg
  • Upload date:
  • Size: 171.8 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py3.7.egg
Algorithm Hash digest
SHA256 db52ea71cebc4ed04bb3f82efd66170cbb1b99fda031c9af5186339807daf437
MD5 0c6ca5b34a7d66b723a12714489c38d2
BLAKE2b-256 e198949373fe0b4bdb8150bf4e5e3775ab50cb01e703122919751f08f8689396

See more details on using hashes here.

Provenance

File details

Details for the file xdis-4.0.0-py3.6.egg.

File metadata

  • Download URL: xdis-4.0.0-py3.6.egg
  • Upload date:
  • Size: 171.8 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py3.6.egg
Algorithm Hash digest
SHA256 2e809a5902cdb81bc179d58ddc5a92daab7575e81ab849f00165c849822eecc3
MD5 c01f217f6c031462f023e691e37f53bc
BLAKE2b-256 f4290572529c41cebef3aeb64a2e624980b8e9d9bffa40464a4461a0d0a251d9

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py3.5.egg
  • Upload date:
  • Size: 174.7 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py3.5.egg
Algorithm Hash digest
SHA256 c7601df074fc835ec1a3d9638becde51109fbe5ba4c8328649d756d09f61465c
MD5 5d226684a622d9fd8b0979ace53afeb5
BLAKE2b-256 1c79524460d347a9617155fc2d34991eadd63cf35bf1863fd5b37e2756cfb556

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py3.4.egg
  • Upload date:
  • Size: 175.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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py3.4.egg
Algorithm Hash digest
SHA256 2b5d4029e2ebb679779708369b9a6915f411a47afb330b90d34874373dff92f6
MD5 c1db196213ae59c5fa1b85b8ef48dd34
BLAKE2b-256 cdaaf2e4816265526c29ec6d597f98547297e7f9bdcb4dad614ea82cc174b717

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py3.3.egg
  • Upload date:
  • Size: 175.9 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py3.3.egg
Algorithm Hash digest
SHA256 588d526e1c69a7629fe53d1a0707a7a6936dab159b014a8496140a84efbafee0
MD5 466b66f30c57c0b201342346a0945d83
BLAKE2b-256 8b5d6cc6d9248921c1a7bed0c2bc1a389291bd57ef0f73844603fdf628a2359c

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py2.7.egg
  • Upload date:
  • Size: 171.8 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py2.7.egg
Algorithm Hash digest
SHA256 69ac92042e10676f50c1b38051c5fa9f10fcdaadb8d4d9b64e5ca97dcaa7cb6e
MD5 0fcb567ebd9402e4753dfed1d9a7b950
BLAKE2b-256 5a61acd3f8807292433133cd6a119e7faaeada44019860d13a432f93469d37dc

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py2.5.egg
  • Upload date:
  • Size: 181.8 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py2.5.egg
Algorithm Hash digest
SHA256 a31b1a9dd9a2014b4509a2cfe0801483d0d8d0a3ecc34380d27137e127599567
MD5 135264b60383a2b7bf9a7b51d18bd894
BLAKE2b-256 4e9b5182a7f62cb611e371877aadb51d987affc76dd0c68b4a57d5b7c46259dd

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: xdis-4.0.0-py2.4.egg
  • Upload date:
  • Size: 184.8 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.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for xdis-4.0.0-py2.4.egg
Algorithm Hash digest
SHA256 1bead97f642baf8387a20043df9c3e6cf118cdca2f4eb57135c5230a581a548d
MD5 a7b38b05ca831d068ea6f796f2e2a6ec
BLAKE2b-256 9f55a7b022457357048885a88c609ecbac39a7f67d8100a1df98f4e6dd07c8bc

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