uncompyle icon indicating copy to clipboard operation
uncompyle copied to clipboard

IMPORT_FROM only takes one LOAD_ATTR

Open gstarnberger opened this issue 14 years ago • 1 comments

Copied from: http://code.google.com/p/unpyc/issues/detail?id=9

decompiling a program that uses:

import a.b.c.d as e

will fail, because the code expects no more then one LOAD_ATTR after a IMPORT_FROM statement.

A work around is to add the following, up to the number of LOAD_ATTR lines you are seeing - I don't currently see a way to tell unpyc to accept any number of them. Starting at line 189 in Parser.py, add: import_as ::= IMPORT_NAME LOAD_ATTR LOAD_ATTR designator import_as ::= IMPORT_NAME LOAD_ATTR LOAD_ATTR LOAD_ATTR designator

etc, etc, etc

Yes, I know this doesn't fit the 0,1,n pattern, but it is a quick fix.

gstarnberger avatar Sep 27 '10 21:09 gstarnberger

Later uncompyle2/uncompyle6 handle this with a list. See https://github.com/rocky/python-uncompyle6/blob/master/uncompyle6/parser.py#L391

rocky avatar May 02 '16 14:05 rocky