[issue38681] 2to3 Conversion Result using BlankLine() can be Syntactically Incorrect

2021-10-20 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed
superseder:  -> Close 2to3 issues and list them here

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38681] 2to3 Conversion Result using BlankLine() can be Syntactically Incorrect

2019-11-08 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
pull_requests: +16602
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17096

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38681] 2to3 Conversion Result using BlankLine() can be Syntactically Incorrect

2019-11-08 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38681] 2to3 Conversion Result using BlankLine() can be Syntactically Incorrect

2019-11-03 Thread Samuel Tatasurya


New submission from Samuel Tatasurya :

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.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 355926
nosy: Samuel Tatasurya
priority: normal
severity: normal
status: open
title: 2to3 Conversion Result using BlankLine() can be Syntactically Incorrect
type: enhancement
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com