Open CarstenGrohmann opened 1 year ago
Please extend the futurize tool to display a warning when ValueError.message is used, or replace the message attribute e.g. with str(<exception>), since ValueError.message no longer exists in Python 3.
futurize
ValueError.message
message
str(<exception>)
$ cat example.py2 #!/usr/bin/env python2.7 try: raise ValueError('Foo') except ValueError as e: print "Caught: %s" % e.message $ futurize example.py2 RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored example.py2 --- example.py2 (original) +++ example.py2 (refactored) @@ -1,5 +1,6 @@ #!/usr/bin/env python2.7 +from __future__ import print_function try: raise ValueError('Foo') except ValueError as e: - print "Caught: %s" % e.message + print("Caught: %s" % e.message) RefactoringTool: Files that need to be modified: RefactoringTool: example.py2
--- example.py2 (original) +++ example.py2 (refactored) @@ -2,4 +2,4 @@ try: raise ValueError('Foo') except ValueError as e: - print "Caught: %s" % e.message + print("Caught: %s" % str(e))
Bug report
Please extend the
futurize
tool to display a warning whenValueError.message
is used, or replace themessage
attribute e.g. withstr(<exception>)
, sinceValueError.message
no longer exists in Python 3.Reproducer
Example of an expected result
My environment