You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-10-20.22:56:56.498>created_at=<Date2019-11-04.07:12:47.801>labels= ['type-feature', 'expert-2to3', '3.9']
title='2to3 Conversion Result using BlankLine() can be Syntactically Incorrect'updated_at=<Date2021-10-20.22:56:56.497>user='https://bugs.python.org/SamuelTatasurya'
Transformation performed by certain fixers (e.g. future, itertools_imports) that causes a statement to be replaced by a blank line will generate a Python file that contains syntax error.
For example, assuming a Python file (foo.py) containing line below:
try:
from itertools import imap
except ImportError:
pass
If we run "itertools_imports" fixer against it:
2to3 -f itertools_imports foo.py
will result in the following:
try:
exceptImportError:
pass
which is syntactically incorrect.
Suggestion:
Instead of always replacing such case with BlankLine(), a check should be performed beforehand if the statement to be replaced has any siblings. If no sibling is found, then replace that statement with a "pass" statement instead.
By doing this, Python source files generated by 2to3 are more readily runnable right after the transformation.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: