New submission from Terry J. Reedy:

Language manual, section 7.8. The raise statement has no mention of the 'from 
None' option. Indeed it says "if given, the second expression must be another 
exception class or instance", which would exclude None.

Library manual, Ch 5. Built-in Exceptions, says
'''
When raising a new exception (rather than using a bare raise to re-raise the 
exception currently being handled), the implicit exception context can be 
supplemented with an explicit cause by using from with raise:

raise new_exc from original_exc

The expression following from must be an exception or None. It will be set as 
__cause__ on the raised exception. Setting __cause__ also implicitly sets the 
__suppress_context__ attribute to True, so that using raise new_exc from None 
effectively replaces the old exception with the new one for display purposes 
(e.g. converting KeyError to AttributeError, while leaving the old exception 
available in __context__ for introspection when debugging.
'''
I am not sure how much should be copied over, but None should be at least 
mentioned and perhaps there should be a cross-reference.

I am also not sure how much applies to 3.2, but there is no version-added or 
-changed note with the above.

----------
assignee: docs@python
components: Documentation
messages: 181939
nosy: docs@python, ncoghlan, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Document 'from None' in raise statement doc.
versions: Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17188>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to