Message326389
Thanks Nick for the details. I think 2to3 uses StdoutRefactoringTool [1] which inherits from RefactoringTool in the chain and implements log_error [2] that logs the error.
StdoutRefactoringTool inherits from MultiprocessRefactoringTool [3] which in turn inherits from RefactoringTool [4] that raises the exception on log_error. But StdoutRefactoringTool re-implemented it to log and not to raise. I couldn't see any errors on scripts that have parsing errors. I think the docstring is right from the context of StdoutRefactoringTool but they were essentially present in RefactoringTool adding to the confusion I hope. Suggestions welcome on improving this. Feel free to correct me if I am misunderstanding the issue.
Example I have used to verify :
$ cat ../backups/bpo32750.py # parse error file should be logged and skipped
foo +- # Invalid file
$ cat ../backups/bpo32750.py # valid file
print "hello"
$ 2to3 ../backups/bpo32750.py ../backups/bpo32750_valid.py
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Can't parse ../backups/bpo32750.py: ParseError: bad input: type=4, value='\n', context=('', (1, 6))
RefactoringTool: Refactored ../backups/bpo32750_valid.py
--- ../backups/bpo32750_valid.py (original)
+++ ../backups/bpo32750_valid.py (refactored)
@@ -1 +1 @@
-print "hello"
+print("hello")
RefactoringTool: Files that need to be modified:
RefactoringTool: ../backups/bpo32750_valid.py
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse ../backups/bpo32750.py: ParseError: bad input: type=4, value='\n', context=('', (1, 6))
Hope this helps.
Thanks again
[1] StdoutRefactoringTool - https://github.com/tirkarthi/cpython/blob/f6c8007a29b95b3ea3ca687a9b4924769a696328/Lib/lib2to3/main.py#L245
[2] StdoutRefactoringTool.log_error - https://github.com/tirkarthi/cpython/blob/f6c8007a29b95b3ea3ca687a9b4924769a696328/Lib/lib2to3/main.py#L65
[3] MultiprocessRefactoringTool - https://github.com/tirkarthi/cpython/blob/f6c8007a29b95b3ea3ca687a9b4924769a696328/Lib/lib2to3/refactor.py#L676
[4] RefactoringTool - https://github.com/tirkarthi/cpython/blob/f6c8007a29b95b3ea3ca687a9b4924769a696328/Lib/lib2to3/refactor.py#L155 |
|
Date |
User |
Action |
Args |
2018-09-25 18:47:37 | xtreak | set | recipients:
+ xtreak, benjamin.peterson, soupytwist |
2018-09-25 18:47:37 | xtreak | set | messageid: <1537901257.22.0.545547206417.issue32750@psf.upfronthosting.co.za> |
2018-09-25 18:47:37 | xtreak | link | issue32750 messages |
2018-09-25 18:47:37 | xtreak | create | |
|