[issue16714] Raise exceptions, don't throw

New submission from Serhiy Storchaka: The proposed patch fixes wording of documentation, comments, etc which use the term 'throw' instead of 'raise' in context of exception raising. ---------- assignee: docs@python components: Documentation files: raise-3.3.patch keywords: patch messages: 177698 nosy: asvetlov, docs@python, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Raise exceptions, don't throw type: enhancement versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file28347/raise-3.3.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: Added file: http://bugs.python.org/file28348/raise-3.2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: Added file: http://bugs.python.org/file28349/raise-2.7.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Changes by Chris Jerdonek <chris.jerdonek@gmail.com>: ---------- nosy: +chris.jerdonek _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Georg Brandl added the comment: 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. ---------- nosy: +georg.brandl _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Serhiy Storchaka added the comment: Indeed. Here are updated patches. ---------- Added file: http://bugs.python.org/file28350/raise-2.7_2.patch Added file: http://bugs.python.org/file28351/raise-3.3_2.patch Added file: http://bugs.python.org/file28352/raise-3.2_2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Andrew Svetlov added the comment: Fixed. Thanks, Serhiy. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Serhiy Storchaka added the comment: 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'. ---------- Added file: http://bugs.python.org/file28360/throw_away.patch Added file: http://bugs.python.org/file28361/throw2raised.patch Added file: http://bugs.python.org/file28362/throw2raised-3.2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Roundup Robot added the comment: New changeset 0a5c5399f638 by Andrew Svetlov in branch '2.7': revert comment wording (#16714) http://hg.python.org/cpython/rev/0a5c5399f638 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Roundup Robot added the comment: 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 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Andrew Svetlov added the comment: Committed. Thanks again, Serhiy! ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: Added file: http://bugs.python.org/file28348/raise-3.2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: Added file: http://bugs.python.org/file28349/raise-2.7.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Changes by Chris Jerdonek <chris.jerdonek@gmail.com>: ---------- nosy: +chris.jerdonek _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Georg Brandl added the comment: 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. ---------- nosy: +georg.brandl _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Serhiy Storchaka added the comment: Indeed. Here are updated patches. ---------- Added file: http://bugs.python.org/file28350/raise-2.7_2.patch Added file: http://bugs.python.org/file28351/raise-3.3_2.patch Added file: http://bugs.python.org/file28352/raise-3.2_2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Andrew Svetlov added the comment: Fixed. Thanks, Serhiy. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Serhiy Storchaka added the comment: 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'. ---------- Added file: http://bugs.python.org/file28360/throw_away.patch Added file: http://bugs.python.org/file28361/throw2raised.patch Added file: http://bugs.python.org/file28362/throw2raised-3.2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Roundup Robot added the comment: New changeset 0a5c5399f638 by Andrew Svetlov in branch '2.7': revert comment wording (#16714) http://hg.python.org/cpython/rev/0a5c5399f638 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Roundup Robot added the comment: 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 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________

Andrew Svetlov added the comment: Committed. Thanks again, Serhiy! ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16714> _______________________________________
participants (5)
-
Andrew Svetlov
-
Chris Jerdonek
-
Georg Brandl
-
Roundup Robot
-
Serhiy Storchaka