<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Le 13/09/11 22:20, Arnaud Delobelle a écrit :
<blockquote
cite="mid:CAJ6cK1ZbUGkckCXiBTA_WUu4dMvWwJZ+u37qoOrUQSVVOGGubQ@mail.gmail.com"
type="cite">
<pre wrap="">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 <a class="moz-txt-link-freetext" href="http://code.google.com/p/unpyc3/">http://code.google.com/p/unpyc3/</a>
Example:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">from unpyc3 import decompile
def foo(x, y, z=3, *args):
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">... global g
... for i, j in zip(x, y):
... if z == i + j or args[i] == j:
... g = i, j
... return
...
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">print(decompile(foo))
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">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.
</pre>
</blockquote>
Hi, trying your code, I have had numbers of errors:<br>
<br>
File "unpyc3.py", line 55, in <module><br>
SETUP_WITH,<br>
NameError: name 'SETUP_WITH' is not defined<br>
<br>
commented it<br>
<br>
File "unpyc3.py", line 58, in <module><br>
STORE_DEREF, DELETE_DEREF,<br>
NameError: name 'DELETE_DEREF' is not defined<br>
<br>
commented it<br>
<br>
File "unpyc3.py", line 96, in dec_module<br>
stream = open(pyc_path, "rb")<br>
UnboundLocalError: local variable 'pyc_path' referenced before
assignment<br>
<br>
change pyc_path to path<br>
<br>
File "unpyc3.py", line 98, in dec_module<br>
code = Code(code_obj)<br>
File "unpyc3.py", line 210, in __init__<br>
for v in code_obj.co_cellvars + code_obj.co_freevars]<br>
AttributeError: 'NoneType' object has no attribute 'co_cellvars'<br>
<br>
...<br>
<br>
Cheers<br>
<br>
<div class="moz-signature">-- <br>
Vincent V.V.<br>
<a href="https://launchpad.net/oqapy">Oqapy</a> . <a
href="https://launchpad.net/qarte+7">Qarte+7</a> . <a
href="https://launchpad.net/paqager">PaQager</a></div>
</body>
</html>