Changes between Version 43 and Version 44 of DeveloperGuidelines/Py_2_3


Ignore:
Timestamp:
07/04/19 19:32:35 (6 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v43 v44  
    7979x = sorted_locale(x)
    8080}}}
     81
     82=== Raise Exceptions Instances ===
     83
     84Python-3 does no longer support the {{{raise E, V, T}}} syntax - the new syntax is {{{raise E(V).with_traceback(T)}}}.
     85
     86However, the traceback is rarely required - and where E is an Exception class (rather than a string), we can use the {{{raise E(V)}}} syntax which works in all Python versions.
     87
     88{{{#!python
     89# Works in Py2, but not in Py3:
     90raise SyntaxError, "Error Message"
     91# Works in all Python versions, hence our Standard:
     92raise SyntaxError("Error Message")
     93}}}
     94
     95If a traceback object must be passed (which is rarely needed), then we must use the PY2 constant to implement alternative statements.
    8196== Usage ==
    8297