RefactoringTool: ParseError: bad input: type=22, value='='

陌路散爱 提交于 2019-12-13 03:12:10

问题


I'm refactoring some python2 code and changing it to python3 using 2to3 module. I've received following parse error:

RefactoringTool: There was 1 error:
RefactoringTool: Can't parse ./helpers/repo.py: ParseError: bad input: type=22, value='=', context=(' ', (45, 25))

Here is a code that yields the error:

    except ImportError as error_msg:  # pragma: no cover                           
        print(' ',  file = sys.stderr) # this is a line that yields error                                          
        print("Could not locate modifyrepo.py", file=sys.stderr)                
        print("That is odd... should be with createrepo", file=sys.stderr)      
        raise ImportError(error_msg)

I have no clue what could be wrong. Can you please help?


回答1:


The problem is that the code that you're trying to convert is not valid Python 2 code.

When running your code using Python 2, you'll get the following error:

  File "repo.py", line 5
    print(' ',  file = sys.stderr) # this is a line that yields error
                     ^
SyntaxError: invalid syntax

It seems like this code already is Python 3 code. Using Python 3 your code does not yield a SyntaxError.



来源:https://stackoverflow.com/questions/57475673/refactoringtool-parseerror-bad-input-type-22-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!