Sitelet https://github.com/python/cpython/issues/60918
Skip to content

Raise exceptions, don't throw #60918

Description

@serhiy-storchaka
BPO 16714
Nosy @birkenfeld, @asvetlov, @cjerdonek, @serhiy-storchaka
Files
  • raise-3.3.patch: Patch for 3.3+
  • raise-3.2.patch: Patch for 3.2
  • raise-2.7.patch: Patch for 2.7
  • raise-2.7_2.patch
  • raise-3.3_2.patch
  • raise-3.2_2.patch
  • throw_away.patch: Revert 'raise' to 'throw'. Patch for 2.7
  • threw2raised.patch: Replace 'threw' to 'raised'. Patch for 3.3 and 3.4
  • threw2raised-3.2.patch: Replace 'threw' to 'raised'. Patch for 2.7 and 3.2
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-12-18.19:28:42.780>
    created_at = <Date 2012-12-18.18:11:28.917>
    labels = ['type-feature', 'docs']
    title = "Raise exceptions, don't throw"
    updated_at = <Date 2012-12-19.20:56:38.455>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2012-12-19.20:56:38.455>
    actor = 'asvetlov'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2012-12-18.19:28:42.780>
    closer = 'asvetlov'
    components = ['Documentation']
    creation = <Date 2012-12-18.18:11:28.917>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['28347', '28348', '28349', '28350', '28351', '28352', '28360', '28361', '28362']
    hgrepos = []
    issue_num = 16714
    keywords = ['patch']
    message_count = 9.0
    messages = ['177698', '177699', '177700', '177701', '177702', '177755', '177779', '177780', '177781']
    nosy_count = 6.0
    nosy_names = ['georg.brandl', 'asvetlov', 'chris.jerdonek', 'docs@python', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue16714'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    Activity

    1. serhiy-storchaka commented on Dec 18, 2012

      @serhiy-storchaka
      MemberAuthor

      The proposed patch fixes wording of documentation, comments, etc which use the term 'throw' instead of 'raise' in context of exception raising.

    2. birkenfeld commented on Dec 18, 2012

      @birkenfeld
      Member

      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.

    3. serhiy-storchaka commented on Dec 18, 2012

      @serhiy-storchaka
      MemberAuthor

      Indeed. Here are updated patches.

    4. python-dev commented on Dec 18, 2012

      python-devmannequin
      Mannequin

      New changeset fdf907708f49 by Andrew Svetlov in branch '3.2':
      Issue bpo-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 bpo-16714: use 'raise' exceptions, don't 'throw'.
      http://hg.python.org/cpython/rev/15a391919deb

      New changeset 7260cf668dd7 by Andrew Svetlov in branch 'default':
      Issue bpo-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 bpo-16714: use 'raise' exceptions, don't 'throw'.
      http://hg.python.org/cpython/rev/8c2635afbfe1

    5. asvetlov commented on Dec 18, 2012

      @asvetlov
      Contributor

      Fixed. Thanks, Serhiy.

    6. serhiy-storchaka commented on Dec 19, 2012

      @serhiy-storchaka
      MemberAuthor

      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'.

    7. python-dev commented on Dec 19, 2012

      python-devmannequin
      Mannequin

      New changeset 0a5c5399f638 by Andrew Svetlov in branch '2.7':
      revert comment wording (bpo-16714)
      http://hg.python.org/cpython/rev/0a5c5399f638

    8. python-dev commented on Dec 19, 2012

      python-devmannequin
      Mannequin

      New changeset b227f8f7242d by Andrew Svetlov in branch '2.7':
      replace threw with raised (bpo-16714)
      http://hg.python.org/cpython/rev/b227f8f7242d

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

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

      New changeset 3594175c6860 by Andrew Svetlov in branch 'default':
      replace threw with raised (bpo-16714)
      http://hg.python.org/cpython/rev/3594175c6860

    9. asvetlov commented on Dec 19, 2012

      @asvetlov
      Contributor

      Committed. Thanks again, Serhiy!

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      docsDocumentation in the Doc dirtype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions