| 81 | |
| 82 | === Raise Exceptions Instances === |
| 83 | |
| 84 | Python-3 does no longer support the {{{raise E, V, T}}} syntax - the new syntax is {{{raise E(V).with_traceback(T)}}}. |
| 85 | |
| 86 | However, 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: |
| 90 | raise SyntaxError, "Error Message" |
| 91 | # Works in all Python versions, hence our Standard: |
| 92 | raise SyntaxError("Error Message") |
| 93 | }}} |
| 94 | |
| 95 | If a traceback object must be passed (which is rarely needed), then we must use the PY2 constant to implement alternative statements. |