homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document 'from None' in raise statement doc.
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Arfrever, Mariatta, benjamin.peterson, berker.peksag, cheryl.sabella, docs@python, ezio.melotti, me@dennis.is, ncoghlan, nitika, rbcollins, serhiy.storchaka, terry.reedy, thomir
Priority: normal Keywords: easy, patch

Created on 2013年02月12日 01:19 by terry.reedy, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch17188.patch me@dennis.is, 2013年02月23日 19:24 review
issue17188.patch nitika, 2014年03月15日 18:27
issue17188_1.patch nitika, 2014年03月19日 19:09
issue17188_3.4.patch thomir, 2016年09月12日 23:03
issue17188_3.4.patch thomir, 2016年09月13日 04:49
issue17188_by_thomir.patch Mariatta, 2016年10月05日 07:11 review
Pull Requests
URL Status Linked Edit
PR 1671 merged cheryl.sabella, 2017年05月20日 00:16
PR 1671 merged cheryl.sabella, 2017年05月20日 00:16
PR 1867 merged cheryl.sabella, 2017年05月30日 20:18
PR 1875 merged Mariatta, 2017年05月30日 21:30
PR 1876 merged Mariatta, 2017年05月30日 22:28
Messages (20)
msg181939 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013年02月12日 01:19
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.
msg182213 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年02月16日 05:38
As Terry notes, the various pieces of "from None" documentation should also have a nearby directive like:
.. versionchanged: 3.3
 :const:`None` permitted as ``Y`` in ``raise X from Y`` 
.. versionadded: 3.3
 The ``__suppress_context__`` attribute to suppress automatic display of the exception context
msg182799 - (view) Author: Dennis Mårtensson (me@dennis.is) * Date: 2013年02月23日 19:24
We have added the from None to the documentation with a explanation and some example code.
msg182815 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2013年02月23日 20:25
The patch should add something to the "The from clause is used for exception..." paragraph, to state that None is also allowed.
It also adds things in a confusing order. I think the new example should go below other examples, and the changedversion and addedversion directives should be the last thing in the section.
msg213640 - (view) Author: Nitika Agarwal (nitika) * Date: 2014年03月15日 05:31
Hi,
As suggested by Petri,I have made some changes.
Please review the attached patch.Any comments and feedback are welcome.
msg214126 - (view) Author: Nitika Agarwal (nitika) * Date: 2014年03月19日 19:09
Patch with some corrections.
Please review the patch attached.
msg214178 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2014年03月20日 07:10
The patch doesn't apply cleanly on 3.4 or default.
msg276132 - (view) Author: Thomi Richards (thomir) * Date: 2016年09月12日 23:03
I have attached a patch for 3.4, based on the patch submitted by Nitika Agarwal. The main difference is that I think it's better to be explicit and show a separate example of `raise X from None`.
I will submit a patch for later versions as well.
msg276133 - (view) Author: Thomi Richards (thomir) * Date: 2016年09月12日 23:07
OK, it seems that patch applies cleanly to 3.5 and 3.6.
msg276170 - (view) Author: Thomi Richards (thomir) * Date: 2016年09月13日 04:49
Re-uploaded the patch without the typo.
msg278110 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2016年10月05日 07:11
reuploaded thomir's patch issue17188_3.4.patch as is.
I take no credit for this.
msg293454 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017年05月10日 21:21
Would any of the original authors be able to prepare a PR for this? Thanks.
msg294011 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017年05月20日 06:48
New changeset 763557eac06ba60d7c5133e4f80df8870d8f917e by terryjreedy (csabella) in branch 'master':
bpo-17188: DOC: Document 'from None' in raise statement (#1671)
https://github.com/python/cpython/commit/763557eac06ba60d7c5133e4f80df8870d8f917e
msg294013 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017年05月20日 06:51
The double listing seems to be a glitch.
Either someone else does backport or online doc change waits until I can do it.
msg294780 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017年05月30日 20:27
New changeset 00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb by Mariatta (csabella) in branch '3.6':
bpo-17188: DOC: Document 'from None' in raise statement (GH-1671) (GH-1867)
https://github.com/python/cpython/commit/00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb
msg294781 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017年05月30日 20:31
Patch has been applied to 3.7 and 3.6.
Thanks everyone :)
msg294786 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017年05月30日 21:15
Seems periods at the ends of sentences are missed.
msg294792 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017年05月30日 22:26
New changeset 9efad1e5aef32a6d8ca288793e8ee6df8782f615 by Mariatta in branch 'master':
bpo-17188: add missing periods at the end of sentences (GH-1875)
https://github.com/python/cpython/commit/9efad1e5aef32a6d8ca288793e8ee6df8782f615
msg294795 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017年05月30日 22:37
New changeset 60b257b01ca497d7a556e3f526704aa1b923d1ac by Mariatta in branch '3.6':
bpo-17188: add missing periods at the end of sentences (GH-1875) (GH-1876)
https://github.com/python/cpython/commit/60b257b01ca497d7a556e3f526704aa1b923d1ac
msg294796 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017年05月30日 22:38
Thanks Serhiy.
I added the missing periods.
History
Date User Action Args
2022年04月11日 14:57:41adminsetgithub: 61390
2017年05月30日 22:38:56Mariattasetmessages: + msg294796
2017年05月30日 22:37:45Mariattasetmessages: + msg294795
2017年05月30日 22:28:17Mariattasetpull_requests: + pull_request1956
2017年05月30日 22:26:44Mariattasetmessages: + msg294792
2017年05月30日 21:30:16Mariattasetpull_requests: + pull_request1955
2017年05月30日 21:15:42serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg294786
2017年05月30日 20:31:02Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg294781

stage: backport needed -> resolved
2017年05月30日 20:27:42Mariattasetmessages: + msg294780
2017年05月30日 20:18:31cheryl.sabellasetpull_requests: + pull_request1949
2017年05月20日 06:51:30terry.reedysetassignee: docs@python -> terry.reedy
stage: patch review -> backport needed
messages: + msg294013
versions: + Python 3.6, Python 3.7, - Python 3.4, Python 3.5
2017年05月20日 06:48:30terry.reedysetmessages: + msg294011
2017年05月20日 00:16:45cheryl.sabellasetpull_requests: + pull_request1766
2017年05月20日 00:16:41cheryl.sabellasetpull_requests: + pull_request1765
2017年05月10日 21:21:24cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg293454
2016年10月05日 07:11:58Mariattasetfiles: + issue17188_by_thomir.patch

messages: + msg278110
2016年10月04日 19:58:20Mariattasetnosy: + Mariatta
2016年09月22日 10:26:02rbcollinssetnosy: + rbcollins
2016年09月13日 07:11:39petri.lehtinensetnosy: - petri.lehtinen
2016年09月13日 04:49:42thomirsetfiles: + issue17188_3.4.patch

messages: + msg276170
2016年09月12日 23:07:19thomirsetmessages: + msg276133
2016年09月12日 23:03:35thomirsetfiles: + issue17188_3.4.patch
nosy: + thomir
messages: + msg276132

2015年01月31日 00:57:01berker.peksagsetnosy: + berker.peksag
stage: needs patch -> patch review

versions: + Python 3.5, - Python 3.3
2014年03月20日 18:44:32Arfreversetnosy: + Arfrever
2014年03月20日 07:10:41petri.lehtinensetmessages: + msg214178
2014年03月19日 19:09:33nitikasetfiles: + issue17188_1.patch

messages: + msg214126
2014年03月15日 18:27:07nitikasetfiles: + issue17188.patch
2014年03月15日 18:25:05nitikasetfiles: - issue17188.patch
2014年03月15日 06:41:41nitikasetfiles: + issue17188.patch
2014年03月15日 06:38:07nitikasetfiles: - issue17188.patch
2014年03月15日 05:31:54nitikasetfiles: + issue17188.patch
nosy: + nitika
messages: + msg213640

2013年12月20日 23:33:54terry.reedylinkissue20003 superseder
2013年02月23日 20:25:23petri.lehtinensetnosy: + petri.lehtinen

messages: + msg182815
versions: - Python 3.2
2013年02月23日 19:24:27me@dennis.issetfiles: + patch17188.patch

nosy: + me@dennis.is
messages: + msg182799

keywords: + patch
2013年02月16日 05:38:43ncoghlansetmessages: + msg182213
2013年02月15日 21:10:13ezio.melottisetkeywords: + easy
nosy: + benjamin.peterson, ezio.melotti
type: enhancement
2013年02月12日 01:19:59terry.reedycreate

AltStyle によって変換されたページ (->オリジナル) /