Skip to main content

pyc_revive

.pyc -> .py reconstructor. no uncompyle6. no pycdc. no xdis.

use

python -m pyc_revive my file.pyc
python -m pyc_revive ./dist/app.pyc --out ./revived.py

input handling: exact path, spaces with no quotes, basename search in cwd + all subfolders + parent folder.

versions

every CPython from 2.0 through 3.15 resolves by magic number (pymagic.py, full table + nearest fallback + header sizes).

two backends, one pipeline:

  • native: .pyc matches the running interpreter. stdlib marshal loads the code object, stdlib dis disassembles. zero dependencies.
  • pycdas: anything else. the bundled pycdas.exe disassembles the foreign version, pycdas_parser.py parses the dump into code trees, shim.py adapts them to the pipeline. everything downstream (normalize, segment, translate, CFG, emit, verify x3) runs unchanged.

pipeline

  1. find file (finder.py)
  2. detect version via magic (pymagic.py)
  3. load: native marshal, else pycdas backend (loader.py, pycdas_parser.py, shim.py)
  4. disassemble + abstract (bytecode.py: Inst, EditableBytecode, opcode/oparg/value-stack/metadata tables)
  5. normalize / mask consts + names (normalizer.py)
  6. opcode-aware B/I/E segmentation (segmenter.py)
  7. statement translation (translator.py: stack machine, defaults recovery, lambdas inline, 2.x print/exec/class ops)
  8. control-flow graph from jumps (cfg.py: if/for/while/try/except-as (bare except: too)/with/finally, clauses + clusters, 3.11+ exception table, SETUP-region splits)
  9. emit + repairs (emitter.py: source-order splicing onto def/class stub lines, bases recovery, @decorator restore, global decls, cond chains, ternaries, nested if/else, loop ranges, break/continue recovery, indent + suite-guard passes)
  10. equivalence verify, 3 sweeps (verifier.py: recompile revived source, compare opcode structure, repair, repeat x3)

layout

pyc_revive/
  finder.py  pymagic.py  loader.py  pycdas_parser.py  shim.py
  bytecode.py  normalizer.py  segmenter.py  translator.py  cfg.py
  emitter.py  verifier.py  reconstructor.py  cli.py  __main__.py
  pycdas.exe  README.md  requirements.txt

known limits

  • inline comprehensions/genexps render as func(...) placeholders.
  • try bodies that fall through into always-run handlers keep flat order instead of guarded flow.
  • exotic decorators reduce to bare defs; exotic call shapes degrade to commented disassembly rather than failing.
  • pre-3.8 default-argument recovery is best-effort (flag-style MAKE from 3.8+ recovers exactly).
  • verifier scores dip across versions: opcode sets drift between releases, so cross-version similarity reads lower than same-version.

Metadata

Release files for pyc-revive 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyc-revive 1.0.0
File Size Uploaded
pyc_revive-1.0.0.tar.gz 784.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyc-revive 1.0.0
File Interpreter ABI Platform
pyc_revive-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.6 MB

Release files / pyc_revive-1.0.0.tar.gz

Download URL pyc_revive-1.0.0.tar.gz
Size 784.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bf870b955d54564841e7ff3c41564c69333a662df9546309894e0eaddda962ee
BLAKE2b-256 checksum
How to use checksums
b520c5443e0a40b97e097dba1f282c9d9e367c58b0ea0c19574591bba756bdf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / pyc_revive-1.0.0-py3-none-any.whl

Download URL pyc_revive-1.0.0-py3-none-any.whl
Size 793.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
783d8046ff7d99193a723746071c56250dda090f980dda89b5e386bf1d4672ba
BLAKE2b-256 checksum
How to use checksums
442b5d6e6d2abb5cc7eea6c17c72c7e3618c674a11118d99f630e759df476e0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release history Release notifications | RSS feed

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page