Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc of three C exception values. #69568

Closed
zhangyangyu opened this issue Oct 12, 2015 · 17 comments
Closed

Update doc of three C exception values. #69568

zhangyangyu opened this issue Oct 12, 2015 · 17 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@zhangyangyu
Copy link
Member

BPO 25381
Nosy @terryjreedy, @ezio-melotti, @bitdancer, @vadmium, @willingc, @jayvdb, @zhangyangyu, @miss-islington, @iritkatriel
PRs
  • bpo-25381: Update explanation of exceptions in C. #26838
  • [3.10] bpo-25381: Update explanation of exceptions in C. (GH-26838) #29568
  • [3.9] bpo-25381: Update explanation of exceptions in C. (GH-26838) #29569
  • Files
  • doc_extending.patch
  • doc_extending2.patch
  • 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 2021-11-15.23:08:42.715>
    created_at = <Date 2015-10-12.08:11:36.406>
    labels = ['3.11', 'type-feature', '3.9', '3.10', 'docs']
    title = 'Update doc of three C exception values.'
    updated_at = <Date 2021-11-15.23:08:42.714>
    user = 'https://github.com/zhangyangyu'

    bugs.python.org fields:

    activity = <Date 2021-11-15.23:08:42.714>
    actor = 'terry.reedy'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-11-15.23:08:42.715>
    closer = 'terry.reedy'
    components = ['Documentation']
    creation = <Date 2015-10-12.08:11:36.406>
    creator = 'xiang.zhang'
    dependencies = []
    files = ['40754', '40766']
    hgrepos = []
    issue_num = 25381
    keywords = ['patch']
    message_count = 17.0
    messages = ['252848', '252858', '252859', '252866', '252867', '252871', '252907', '252913', '252917', '252930', '252933', '396280', '396291', '396292', '406364', '406367', '406368']
    nosy_count = 10.0
    nosy_names = ['terry.reedy', 'ezio.melotti', 'r.david.murray', 'docs@python', 'martin.panter', 'willingc', 'jayvdb', 'xiang.zhang', 'miss-islington', 'iritkatriel']
    pr_nums = ['26838', '29568', '29569']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25381'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @zhangyangyu
    Copy link
    Member Author

    In the first paragraph of https://docs.python.org/3/extending/extending.html#intermezzo-errors-and-exceptions,
    it is wrong to use the sentence "the second argument to raise" since
    the raise syntax has been changed in Python3.

    @zhangyangyu zhangyangyu added the docs Documentation in the Doc dir label Oct 12, 2015
    @vstinner vstinner changed the title Use old description of raise in Python3 Doc: Use old description of raise in Python3 Oct 12, 2015
    @bitdancer
    Copy link
    Member

    Looks good to me.

    @bitdancer bitdancer changed the title Doc: Use old description of raise in Python3 Doc: Use of old description of raise in Python3 Oct 12, 2015
    @bitdancer
    Copy link
    Member

    Actually, I take that back. Shouldn't it be "the object passed *as* the exception object to raise?

    @zhangyangyu
    Copy link
    Member Author

    With this sentence

    A second global variable stores the “associated value” of the exception (the second argument to raise).

    I think the phrase inside the parentheses is to explain the "associated value", which is usually a string passed to the exception object, not the exception object itself.

    Do I misunderstand anything?

    @bitdancer
    Copy link
    Member

    Yes. The second element of the sys.exc_info result is the exception instance, not the argument to the exception constructor. The old raise syntax allowed you to specify the exception instance as the second argument to raise, but if you specified a string it converted it to an exception instance using the first argument as the constructor to call. So, the 2.7 docs aren't entirely accurate, since it isn't the second argument to raise that is stored, but the object that results from raise *processing* its second argument.

    @zhangyangyu
    Copy link
    Member Author

    Oops, I misunderstand sys.exc_info all the time, sad :(

    Now, both versions of doc are not correct. Please make them fixed.

    @zhangyangyu
    Copy link
    Member Author

    I fix my patch with David's comment.

    @vadmium
    Copy link
    Member

    vadmium commented Oct 13, 2015

    “Associated value” still seems a bit weird. I wonder if it would be clearer to say

    The exception type is stored in a static global variable . . . A second global variable stores the exception instance passed to :keyword:`raise` . . .

    Also further down that section it looks like there are other problems. “Exception object” is perhaps actually a C object referencing the exception class (type). ‘Python string object . . . stored as the "associated value" ’ should perhaps be the exception instance (object). I think a long time ago Python may have actually worked this way, but not any more, and the whole section probably needs updating.

    @zhangyangyu
    Copy link
    Member Author

    Yes, you are right martin. It seems the whole chapter needs more updates, not only the bits I mentioned. I won't provide a new patch since I am not an English native and I am not sure I can provide an accurate and right description. Hope someone else may help.

    @bitdancer
    Copy link
    Member

    There's also the fact that the argument to raise can be an exception class, but the second element of sys.exc_info is still an instance of that class, which only occurred to me while reading your revised patch.

    @zhangyangyu
    Copy link
    Member Author

    Actually what I intend is that the exception object passed to raise is the exception instance raise finally throws (what is stored in the second variable). So it seems wise not to do any more for me. A single sentence has lead to confusion, not to mention more.

    @ezio-melotti ezio-melotti added the type-feature A feature request or enhancement label Jan 4, 2016
    @iritkatriel iritkatriel added the 3.11 only security fixes label Jun 21, 2021
    @terryjreedy
    Copy link
    Member

    Irit, it is unclear why you unchecked 'patch'. Because no PR? The keyword includes a patch file attached to an issue. Someone can convert it to a PR. From the tracker doc:
    "patch There is a patch or pull request attached to the issue."

    Because the 2nd patch was, in essence rejected as is? A different matter, though most .patch or .diff files attached need revision when made a PR.

    @terryjreedy
    Copy link
    Member

    On 2007 Aug 15, extending.rst was merged into master (early 2.6 alpha) and early 3.0 alpha. The only change to this paragraph since the initial 2.6 version was Serhiy changing "NULL" to "NULL" in 3.x on 2019 Oct 30. I will post a PR with what I think is true now.

    @terryjreedy terryjreedy added 3.9 only security fixes 3.10 only security fixes labels Jun 21, 2021
    @iritkatriel
    Copy link
    Member

    Yes, I thought since we need a PR the keyword was wrong. Thanks for the correction.

    @terryjreedy terryjreedy changed the title Doc: Use of old description of raise in Python3 Update doc of three C exception values. Jun 22, 2021
    @willingc
    Copy link
    Contributor

    New changeset ad43dc0 by Terry Jan Reedy in branch 'main':
    bpo-25381: Update explanation of exceptions in C. (GH-26838)
    ad43dc0

    @terryjreedy
    Copy link
    Member

    New changeset 0320cf1 by Miss Islington (bot) in branch '3.10':
    bpo-25381: Update explanation of exceptions in C. (GH-26838) (GH-29568)
    0320cf1

    @terryjreedy
    Copy link
    Member

    New changeset b0bdc09 by Miss Islington (bot) in branch '3.9':
    bpo-25381: Update explanation of exceptions in C. (GH-26838) (GH-29569)
    b0bdc09

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    7 participants