[New-bugs-announce] [issue15209] Re-raising exceptions from an expression

Tyler Crompton report at bugs.python.org
Wed Jun 27 20:27:46 CEST 2012

New submission from Tyler Crompton <gtr053 at gmail.com>:

As you know, a caught exception can be re-raised with a simple `raise` statement. Plain and simple. However, one cannot re-raise an error with this new `"from" expression` clause.

For example:

    def getch(prompt=''):
        '''Get and return a character (similar to `input()`).'''

        print(prompt, end='')
            return windows_module.getch()
        except NameError:
            except Exception:
                raise from None


      File "getch.py", line 11
        raise from None
    SyntaxError: invalid syntax

A quick look at the documentation about [raise](http://docs.python.org/dev/reference/simple_stmts.html#the-raise-statement) confirms that this is the intended behavior. In my opinion, one should be able to still re-raise from an expression.

components: Interpreter Core
files: getch.py
messages: 164184
nosy: Tyler.Crompton
priority: normal
severity: normal
status: open
title: Re-raising exceptions from an expression
type: enhancement
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file26183/getch.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list