-
-
Notifications
You must be signed in to change notification settings - Fork 444
Fix const list for python 2.7 bytecode with uncompyle6 on python 3 #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This is currently not a problem in the current uncompyle6 master. Note, however, that due to an API change in xdis, you'll also need the master branch of xdis to use it. As for the redundant return, that is a different problem. |
|
@rocky That's weird. I use uncompyle6 master and xdis master , the issue still exist. # uncompyle6 version 3.9.4.dev0
# Python bytecode version base 2.7 (62211)
# Decompiled from: Python 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]
# Embedded file name: /cwd/test.py
# Compiled at: 2025-11-25 16:49:49
test = [
0, 1, 2, 3, 4, 5]My environment: I'm using uncompyle6 on Python 3.12 to decompile Python 2.7 pyc, maybe that's the reason it behaves different? |
|
Yes it's working on Python 2 but not on Python 3. |
Thanks for the information. I will look at this when I get a chance. |
|
I have a feeling this still might be an xdis bug. That package is supposed to make doing this stuff easier and uniform, so version tests should not be needed. But again, I don't have time right now to investigate. |
|
With a little more investigation, here is what I am seeing. LOAD_CONST is of optype "constant opcode" (which means its opcode value is found in the constants table. That information doesn't seem to be propagated in optype and it should also get propagated into the pseudo token's "ADD_VALUE" field. And then based on that (not the Python version) should uncompyle6 be able figure out what datatype the numeric operand is. I realize this may seem a bit detailed and picayune, but my experience is that to cover all kinds of bytecode, separating concerns of what goes where helps in the long run. |
|
@wangym5106, please look at #523 and let me know if this fixes the problem while not breaking other things. |
Example:
Decompiled result:
The issue seems caused by 8a1fd7e and 9fd139a , removed logic for Python 2
This PR recovers the logic and fix the issue