-
Notifications
You must be signed in to change notification settings - Fork 295
Open
Description
I'm getting this error when I attempt to run pasteurize on my code:
c:\Python\PycharmProjects\GooeyGUI\Pasture>pasteurize -w PySimpleGUI.py
RefactoringTool: Can't parse PySimpleGUI.py: ParseError: bad input: type=1, value='exec', context=(' ', (10134, 33))
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse PySimpleGUI.py: ParseError: bad input: type=1, value='exec', context=(' ', (10134, 33))
I've been able to get around most incompatible problems by adding this if statement:
if sys.version_info[0] >= 3:
# do version 3 stuff here
else:
# do version 2 stuff here
It's been working GREAT so far and it's allowed me to ship both Python 2.7 and Python 3 versions of PySimpleGUI.
My if statement trick doesn't work on this exec call.
Here is the code that is failing:
try:
result = eval('{}'.format(cmd), myglobals, mylocals)
except Exception as e:
if sys.version_info[0] < 3:
result = 'Not available in Python 2'
else:
try:
result = exec('{}'.format(cmd), myglobals, mylocals)
except Exception as e:
result = 'Exception {}\n'.format(e)I've also tried defining my own exec function if it's version 2, but it still fails with this error.
Is there a way to make exec calls in Python 2 or a way to have the parser ignore this statement?
Metadata
Metadata
Assignees
Labels
No labels