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 modfiy 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.4.tar.gz (191.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.4-py36-none-any.whl (85.1 kB view details)

Uploaded Python 3.6

xdis-3.8.4-py35-none-any.whl (85.1 kB view details)

Uploaded Python 3.5

xdis-3.8.4-py34-none-any.whl (85.1 kB view details)

Uploaded Python 3.4

xdis-3.8.4-py33-none-any.whl (87.7 kB view details)

Uploaded Python 3.3

xdis-3.8.4-py27-none-any.whl (87.7 kB view details)

Uploaded Python 2.7

xdis-3.8.4-py26-none-any.whl (87.7 kB view details)

Uploaded Python 2.6

xdis-3.8.4-py3.6.egg (169.1 kB view details)

Uploaded Egg

xdis-3.8.4-py3.5.egg (171.9 kB view details)

Uploaded Egg

xdis-3.8.4-py3.4.egg (172.4 kB view details)

Uploaded Egg

xdis-3.8.4-py3.3.egg (173.1 kB view details)

Uploaded Egg

xdis-3.8.4-py2.7.egg (168.8 kB view details)

Uploaded Egg

xdis-3.8.4-py2.6.egg (169.1 kB view details)

Uploaded Egg

xdis-3.8.4-py2.5.egg (178.9 kB view details)

Uploaded Egg

xdis-3.8.4-py2.4.egg (181.7 kB view details)

Uploaded Egg

File details

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

File metadata

  • Download URL: xdis-3.8.4.tar.gz
  • Upload date:
  • Size: 191.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4.tar.gz
Algorithm Hash digest
SHA256 6b6b44f90b55cc4099834ec4a92ac93717e00871dfcbaed6b5390e331ea34461
MD5 2b6997f9ca21e51a26c828204255ad39
BLAKE2b-256 b2588a67d195c819f61094e203aa4e6d59d58a89c0c971d4a5d9e25e047e39b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xdis-3.8.4-py36-none-any.whl
Algorithm Hash digest
SHA256 c825903a001bda65456e0cb9b9bd45f694b2462402b2d066eea191efb45792af
MD5 e1ec6567b53c31f7ced3960a8dfdcd3a
BLAKE2b-256 ca08305614a561a80d41858d275c05da4a80fda99238780787e673b3c5e7946b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xdis-3.8.4-py35-none-any.whl
Algorithm Hash digest
SHA256 a7e3efe32ba4bfe6635ea0bc180806e398292709fb007819b60587b1b93fe7d5
MD5 2ad22e912bc2efa36cfa975fb2a2c6a7
BLAKE2b-256 c5a39b896f5ed9ea76e1f0de5c93634fb8403e70f7e3614e4a8c97758d7539aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xdis-3.8.4-py34-none-any.whl
Algorithm Hash digest
SHA256 698a80ec88a84379a302923c5e68d0e15ea078de53bfe8a5ae51af9558b91c16
MD5 426f8cee0610af8d972a8d2b51755e16
BLAKE2b-256 674d1a3dba94913b28f05bb4892c36aa603cb45a1b197129423cda102b8f5483

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xdis-3.8.4-py33-none-any.whl
Algorithm Hash digest
SHA256 ee701b92710bbb2de8e316e7425a051b19c228107b14105a0a1db3fe0d5179d6
MD5 95e6d7a0946d65ebdd8b534497443230
BLAKE2b-256 ca7ad0eb4054b9b3c04ae489d884e76427cbe95bb50ae87edcf9dcbeea5c3aef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xdis-3.8.4-py27-none-any.whl
Algorithm Hash digest
SHA256 a5dbe376867648df4cc30f701fd90671816803ffa819914ea62000780f4bab7f
MD5 1a5e49e7d38a78b2c15ad54093a5760c
BLAKE2b-256 8122137bef059576d9ad19c6e71f7ca96e5e869056a9a1f2f090548e74744027

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xdis-3.8.4-py26-none-any.whl
Algorithm Hash digest
SHA256 8ddf6ced5b136f7a323971d80efabebb52565cc72dd4ba5a0d9e3ec886e7a6d2
MD5 adae9827c63e2ca608418e051cab841b
BLAKE2b-256 2d807215fc5e3292a249667a65dd218f5aa4dfde72abea7fac691068fa66da57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py3.6.egg
  • Upload date:
  • Size: 169.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py3.6.egg
Algorithm Hash digest
SHA256 c1a70e2565bafd2702a2b17cc35a1fba98ee4118162f8f23e2aaf17180f7101a
MD5 643e47522577cea9c188fdf5226cadae
BLAKE2b-256 377a207b6b1ea543f2f3e0f7a69454f3b16ef982385dcee166b3f14983ea40e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py3.5.egg
  • Upload date:
  • Size: 171.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py3.5.egg
Algorithm Hash digest
SHA256 9a5c1c03f4449695f2b6c6fe9452e660fa736b5326b799ad07f573d5b85b31c8
MD5 9e6307e4056fdeb93c865515c6f33458
BLAKE2b-256 99892d122e3ee1387d0d18effa47841335109d203d1fa359e03505769b1d69af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py3.4.egg
  • Upload date:
  • Size: 172.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py3.4.egg
Algorithm Hash digest
SHA256 89044546d17a0d4b663cc7f11547429afe8e7d6e15826b755b928f2b40c76b8f
MD5 5d6520fc9321d4582479c07405c2ab10
BLAKE2b-256 a18ac717cdef0a1b707df50227f406b297dfd872d6f4d320d4a7688f730d9ba2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py3.3.egg
  • Upload date:
  • Size: 173.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py3.3.egg
Algorithm Hash digest
SHA256 54fe37eeb0e0807cf5860acca5e29d0b6ef1ef0675939a6881ca8d041d1b6e10
MD5 0be7297860f147456eab54625a6f446f
BLAKE2b-256 c41008dd875a00a2c7e37a20d1a2d491bbeb6104c0e177e3953c14987a624496

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py2.7.egg
  • Upload date:
  • Size: 168.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py2.7.egg
Algorithm Hash digest
SHA256 a9b2d6bcc156970c80c2b1272c02017c3b36bd3a831e3868ddef7e6cda7ec71e
MD5 31af631db8deb40c0eed5e93b5b52979
BLAKE2b-256 bbc5a6508eb6f0d2fd4c3aee46a13d0007266e7c13a324b1b5f898935fdca3ae

See more details on using hashes here.

File details

Details for the file xdis-3.8.4-py2.6.egg.

File metadata

  • Download URL: xdis-3.8.4-py2.6.egg
  • Upload date:
  • Size: 169.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py2.6.egg
Algorithm Hash digest
SHA256 3cca0a2bae9e2055285dd29c701dea86c89d04cf95ffc67339f4c4f44bc7f1b2
MD5 4307499d206ba3e2a729fc3668245f96
BLAKE2b-256 3c4f00e4e5e2dcf9d6ed02795d5b1a5a67d936ebe9bd8643d300c620a584bf72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py2.5.egg
  • Upload date:
  • Size: 178.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py2.5.egg
Algorithm Hash digest
SHA256 b78106a4c5af3098baf8bfe349af2c4f9f9192cd6032f6b0694d171116f40d46
MD5 50efdc791fa2b85327b447ed65ccfcfd
BLAKE2b-256 9926c7ebfe6c7dc0692db4cc5f647921603d4374725c91707a5f8aace5f6effd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xdis-3.8.4-py2.4.egg
  • Upload date:
  • Size: 181.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xdis-3.8.4-py2.4.egg
Algorithm Hash digest
SHA256 19c5d87064d31b21a67cca7d2977084664d02f06cb82ea520e2320a4f0385145
MD5 d0a25aa0f1deff10d4f8855de888d433
BLAKE2b-256 caafe8400282fc2410c7f068176ef6b1d8f3a3fe79bd5c50f740fd8183dde830

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