Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:ANN': 0.02; 'example:': 0.03; 'below)': 0.05; 'python': 0.08; 'assert': 0.09; 'declarations': 0.09; 'todo:': 0.09; 'files.': 0.09; 'subject:python': 0.11; 'def': 0.15; '*args):': 0.16; 'constructs': 0.16; 'docstrings': 0.16; 'received:209.85.213.174': 0.16; 'received:mail-yx0-f174.google.com': 0.16; 'reconstructs': 0.16; 'subject:Python3': 0.16; 'thoroughly.': 0.16; '>>>': 0.18; 'arguments': 0.18; 'url:code': 0.23; 'objects,': 0.23; 'welcome.': 0.23; 'code': 0.25; 'code.': 0.26; 'tried': 0.26; 'function': 0.27; 'all,': 0.28; '(see': 0.28; 'import': 0.28; 'message- id:@mail.gmail.com': 0.29; 'module': 0.30; 'recreate': 0.30; 'modules': 0.31; 'version': 0.32; 'source': 0.33; 'probably': 0.33; 'to:addr:python-list': 0.33; 'project': 0.34; 'totally': 0.35; 'google': 0.36; 'file': 0.36; 'another': 0.37; 'statements': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'more': 0.60; 'url:p': 0.62; 'show': 0.67; 'fun!': 0.67; 'note:': 0.68; 'discovered': 0.68; ':).': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=B64jnZnqfBQux2/jh1KKhM8/h1L5+2ylM6dRBajUNY0=; b=Fvi+8JEBYy4+cZdhuA5hxlpzyaakRyLuc5adtHRO2KvIELApESRIZTYTdnyciw0dEX 7hPg89a2y2hw/w6H40IWMCksyHmiplKSWBNuEHvnzp1Yj7aBrFICt8lQ/89+7zukR9Iv j780l4blhPxqcFOapubs5LMhuCMH7hI/zlfuI= MIME-Version: 1.0 Date: Tue, 13 Sep 2011 21:20:16 +0100 Subject: ANN: unpyc3 - a python bytecode decompiler for Python3 From: Arnaud Delobelle To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315945219 news.xs4all.nl 2420 [2001:888:2000:d::a6]:52964 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13241 Hi all, Unpyc3 can recreate Python3 source code from code objects, function source code from function objects, and module source code from .pyc files. The current version is able to decompile itself successfully :). It has been tested with Python3.2 only. It currently reconstructs most of Python 3 (see TODO below) constructs but probably needs to be tested more thoroughly. All feedback welcome. Unpyc3 is a single file and is available at http://code.google.com/p/unpyc3/ Example: >>> from unpyc3 import decompile >>> def foo(x, y, z=3, *args): ... global g ... for i, j in zip(x, y): ... if z == i + j or args[i] == j: ... g = i, j ... return ... >>> print(decompile(foo)) def foo(x, y, z=3, *args): global g for i, j in zip(x, y): if z == i + j or args[i] == j: g = i, j return TODO: * Support for keyword-only arguments * Handle assert statements * Show docstrings for functions and modules * Nice spacing between function/class declarations Have fun! Note: unpyc3 is totally unrelated to another project called "unpyc" which I discovered when I tried to register the same project name on google code. -- Arnaud