Message164184
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='')
try:
return windows_module.getch()
except NameError:
try:
fallback_module.getch()
except Exception:
raise from None
Output:
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. |
|
Date |
User |
Action |
Args |
2012-06-27 18:27:46 | Tyler.Crompton | set | recipients:
+ Tyler.Crompton |
2012-06-27 18:27:45 | Tyler.Crompton | set | messageid: <1340821665.84.0.121596566188.issue15209@psf.upfronthosting.co.za> |
2012-06-27 18:27:44 | Tyler.Crompton | link | issue15209 messages |
2012-06-27 18:27:43 | Tyler.Crompton | create | |
|