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: Raise exceptions, don't throw
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, chris.jerdonek, docs@python, georg.brandl, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2012-12-18 18:11 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
raise-3.3.patch serhiy.storchaka, 2012-12-18 18:11 Patch for 3.3+ review
raise-3.2.patch serhiy.storchaka, 2012-12-18 18:12 Patch for 3.2 review
raise-2.7.patch serhiy.storchaka, 2012-12-18 18:13 Patch for 2.7 review
raise-2.7_2.patch serhiy.storchaka, 2012-12-18 19:02 review
raise-3.3_2.patch serhiy.storchaka, 2012-12-18 19:02 review
raise-3.2_2.patch serhiy.storchaka, 2012-12-18 19:02 review
throw_away.patch serhiy.storchaka, 2012-12-19 16:17 Revert 'raise' to 'throw'. Patch for 2.7 review
threw2raised.patch serhiy.storchaka, 2012-12-19 16:17 Replace 'threw' to 'raised'. Patch for 3.3 and 3.4 review
threw2raised-3.2.patch serhiy.storchaka, 2012-12-19 16:17 Replace 'threw' to 'raised'. Patch for 2.7 and 3.2 review
Messages (9)
msg177698 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-18 18:11
The proposed patch fixes wording of documentation, comments, etc which use the term 'throw' instead of 'raise' in context of exception raising.
msg177699 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-12-18 18:41
LGTM, except for:

diff -r 907d71668d3c Python/pythonrun.c
--- a/Python/pythonrun.c	Sun Dec 16 21:10:35 2012 +0100
+++ b/Python/pythonrun.c	Tue Dec 18 19:35:27 2012 +0200
@@ -2518,7 +2518,7 @@
 PyOS_CheckStack(void)
 {
     __try {
-        /* alloca throws a stack overflow exception if there's
+        /* alloca raises a stack overflow exception if there's
            not enough space left on the stack */
         alloca(PYOS_STACK_MARGIN * sizeof(void*));
         return 0;

This is talking about a C++ exception and therefore "throw" is correct.
msg177700 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-18 19:02
Indeed. Here are updated patches.
msg177701 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-18 19:27
New changeset fdf907708f49 by Andrew Svetlov in branch '3.2':
Issue #16714: use 'raise' exceptions, don't 'throw'.
http://hg.python.org/cpython/rev/fdf907708f49

New changeset 15a391919deb by Andrew Svetlov in branch '3.3':
Issue #16714: use 'raise' exceptions, don't 'throw'.
http://hg.python.org/cpython/rev/15a391919deb

New changeset 7260cf668dd7 by Andrew Svetlov in branch 'default':
Issue #16714: use 'raise' exceptions, don't 'throw'.
http://hg.python.org/cpython/rev/7260cf668dd7

New changeset 8c2635afbfe1 by Andrew Svetlov in branch '2.7':
Issue #16714: use 'raise' exceptions, don't 'throw'.
http://hg.python.org/cpython/rev/8c2635afbfe1
msg177702 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-18 19:28
Fixed. Thanks, Serhiy.
msg177755 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-19 16:17
I found one error. In Lib/email/header.py for 2.7 'raise' should be
reverted to 'throw'.

Also I miss a past form. Second patch replaces 'threw' with 'raised'.
msg177779 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-19 20:47
New changeset 0a5c5399f638 by Andrew Svetlov in branch '2.7':
revert comment wording (#16714)
http://hg.python.org/cpython/rev/0a5c5399f638
msg177780 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-19 20:55
New changeset b227f8f7242d by Andrew Svetlov in branch '2.7':
replace threw with raised (#16714)
http://hg.python.org/cpython/rev/b227f8f7242d

New changeset 74da2dbb5e50 by Andrew Svetlov in branch '3.2':
replace threw with raised (#16714)
http://hg.python.org/cpython/rev/74da2dbb5e50

New changeset 55d86476d048 by Andrew Svetlov in branch '3.3':
replace threw with raised (#16714)
http://hg.python.org/cpython/rev/55d86476d048

New changeset 3594175c6860 by Andrew Svetlov in branch 'default':
replace threw with raised (#16714)
http://hg.python.org/cpython/rev/3594175c6860
msg177781 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-19 20:56
Committed. Thanks again, Serhiy!
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60918
2012-12-19 20:56:38asvetlovsetmessages: + msg177781
2012-12-19 20:55:54python-devsetmessages: + msg177780
2012-12-19 20:47:15python-devsetmessages: + msg177779
2012-12-19 16:17:59serhiy.storchakasetfiles: + throw_away.patch, threw2raised.patch, threw2raised-3.2.patch

messages: + msg177755
2012-12-18 19:28:42asvetlovsetstatus: open -> closed
resolution: fixed
messages: + msg177702

stage: patch review -> resolved
2012-12-18 19:27:57python-devsetnosy: + python-dev
messages: + msg177701
2012-12-18 19:02:43serhiy.storchakasetfiles: + raise-2.7_2.patch, raise-3.3_2.patch, raise-3.2_2.patch

messages: + msg177700
2012-12-18 18:41:26georg.brandlsetnosy: + georg.brandl
messages: + msg177699
2012-12-18 18:17:21chris.jerdoneksetnosy: + chris.jerdonek
2012-12-18 18:13:42serhiy.storchakalinkissue16648 dependencies
2012-12-18 18:13:11serhiy.storchakasetfiles: + raise-2.7.patch
2012-12-18 18:12:13serhiy.storchakasetfiles: + raise-3.2.patch
2012-12-18 18:11:29serhiy.storchakacreate