Message355926
| Author |
Samuel Tatasurya |
| Recipients |
Samuel Tatasurya |
| Date |
2019年11月04日.07:12:47 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1572851567.83.0.781319798867.issue38681@roundup.psfhosted.org> |
| In-reply-to |
| Content |
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:
except ImportError:
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2019年11月04日 07:12:47 | Samuel Tatasurya | set | recipients:
+ Samuel Tatasurya |
| 2019年11月04日 07:12:47 | Samuel Tatasurya | set | messageid: <1572851567.83.0.781319798867.issue38681@roundup.psfhosted.org> |
| 2019年11月04日 07:12:47 | Samuel Tatasurya | link | issue38681 messages |
| 2019年11月04日 07:12:47 | Samuel Tatasurya | create |
|