#15990: Python 3 preparation: Change syntax of raise statement
----------------------------+----------------------------
   Reporter:  wluebbe       |            Owner:
       Type:  enhancement   |           Status:  new
   Priority:  major         |        Milestone:  sage-6.2
  Component:  distribution  |         Keywords:  python3
  Merged in:                |          Authors:
  Reviewers:                |  Report Upstream:  N/A
Work issues:                |           Branch:
     Commit:                |     Dependencies:
   Stopgaps:                |
----------------------------+----------------------------
 Only the modern syntax like {{{raise E(V)}}} and {{{raise
 E(V).with_traceback(T)}}} is accepted by Python 3.[[br]]
 Almost all cases change {{{raise E, V}}} to {{{raise E(V)}}} where V is a
 string.

 **TODO**:
 * Clarify why the cases {{{with_traceback}}} were omitted in
 {{{libfuturize/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.
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15990>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to