-
-
Notifications
You must be signed in to change notification settings - Fork 703
Closed
Milestone
Description
Only the modern syntax like raise E(V) and raise E(V).with_traceback(T) is accepted by Python 3.
Almost all cases change raise E, V to raise E(V) where V is a string.
TODO:
- Clarify why the cases
with_tracebackwere omitted inlibfuturize/fixes/raise.py. (Perhaps this belongs to stage 2?)
Changes according to lib2to3/fixes/fix_raise.py:
raise -> raise
raise E -> raise E
raise E, V -> raise E(V)
raise E, V, T -> raise E(V).with_traceback(T)
raise E, None, T -> raise E.with_traceback(T)
raise (((E, E'), E''), E'''), V -> raise E(V)
raise "foo", V, T -> warns about string exceptions
CAVEATS:
"raise E, V" will be incorrectly translated if V is an exception
instance. The correct Python 3 idiom is
raise E from V
but since we can't detect instance-hood by syntax alone and since
any client code would have to be changed as well, we don't automate
this.
CC: @tscrim
Component: distribution
Author: Wilfried Luebbe
Branch/Commit: 136948a
Reviewer: R. Andrew Ohana
Issue created by migration from https://trac.sagemath.org/ticket/15990