[New-bugs-announce] [issue40547] 2to3 raise can silently remove code from old 2.4 string exceptions

Rémy Oudompheng report at bugs.python.org
Thu May 7 12:37:14 EDT 2020


New submission from Rémy Oudompheng <remyoudompheng at gmail.com>:

When running "2to3 -f raise" on the following code, which uses an old Python 2.4 raise of a string:

def f():
    raise ("message %s %s" % (1, 2))

try:
    f()
finally:
    pass

I obtain the following quite surprising result. I would have expected to get either an error or leave the original file unchanged, because "raise (s)" is syntactically valid although incorrect. 

$ 2to3 -f raise w.py
RefactoringTool: Refactored w.py
--- w.py	(original)
+++ w.py	(refactored)
@@ -1,5 +1,5 @@
 def f():
-    raise ("message %s %s" % (1, 2))
+    raise "message %s %s"
 
 try:
     f()

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 368355
nosy: Rémy Oudompheng
priority: normal
severity: normal
status: open
title: 2to3 raise can silently remove code from old 2.4 string exceptions
type: behavior
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40547>
_______________________________________


More information about the New-bugs-announce mailing list