Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-67377: Document that PyErr_SetString, etc. chain exceptions#20329

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cjerdonek wants to merge6 commits intopython:main
base:main
Choose a base branch
Loading
fromcjerdonek:issue-23188-set-object-docs

Conversation

cjerdonek
Copy link
Member

@cjerdonekcjerdonek commentedMay 23, 2020
edited by AlexWaygood
Loading

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commentedMay 25, 2020
edited
Loading

It is not clear what "caught" mean. The rough equivalent of the Python code:

try:    ...exceptAttributeError:raisesTypeError

is the C code:

...if (result==NULL) {if (PyErr_ExceptionMatches(PyExc_AttributeError)) {PyErr_SetNone(PyExc_TypeError);    }returnNULL;}

Is an AttributeError exception caught here?

ZackerySpytz reacted with thumbs up emoji

@cjerdonek
Copy link
MemberAuthor

The precise condition inside_PyErr_SetObject is if_PyErr_GetTopmostException returns a non-None value:

cpython/Python/errors.c

Lines 117 to 119 inbe63019

exc_value=_PyErr_GetTopmostException(tstate)->exc_value;
if (exc_value!=NULL&&exc_value!=Py_None) {
/* Implicit exception chaining */

However, this is a private function.

So some other ways to say this (without reference to C functions) are (1) if there's an "active exception" (the wording indo_raise()'sRuntimeError message), (2) if an exception is currently being handled (anywhere on the stack), or (3) ifsys.exc_info() would return an exception.

sys.exc_info()'s documentation
https://docs.python.org/3/library/sys.html#sys.exc_info

Do you have a preference?

@JelleZijlstraJelleZijlstra changed the titlebpo-23188: Document that PyErr_SetString, etc. chain exceptionsgh-67377: Document that PyErr_SetString, etc. chain exceptionsApr 14, 2022
@JelleZijlstra
Copy link
Member

I would say "active exception". Could you make that change? In that case, I can merge this PR unless@serhiy-storchaka has further comments.

serhiy-storchaka reacted with thumbs up emoji

@serhiy-storchaka
Copy link
Member

Is the term "active exception" explained anywhere? Should not a link be added?

JelleZijlstra reacted with thumbs up emoji

@JelleZijlstra
Copy link
Member

The term used by thePyErr_Occurred docs is "the error indicator is set".

@serhiy-storchakaserhiy-storchaka added needs backport to 3.10only security fixes needs backport to 3.11only security fixes and removed needs backport to 3.9only security fixes labelsMay 20, 2022
@hugovkhugovk removed the needs backport to 3.10only security fixes labelApr 7, 2023
@furkanonder
Copy link
Contributor

LGTM.@serhiy-storchaka Can you review it?

@hugovkhugovk added the needs backport to 3.12only security fixes labelSep 11, 2023
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@@ -124,7 +124,10 @@ Raising exceptions

These functions help you set the current thread's error indicator.
For convenience, some of these functions will always return a
``NULL`` pointer for use in a ``return`` statement.
``NULL`` pointer for use in a ``return`` statement. Also, for all of the
functions in this subsection, if an exception has already been caught,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@serhiy-storchaka raised an issue with this terminology, I don't think the previous reviewers' comments have been addressed:#20329 (comment)

@hugovkhugovk removed the needs backport to 3.11only security fixes labelApr 11, 2024
@serhiy-storchakaserhiy-storchaka added the needs backport to 3.13bugs and security fixes labelMay 9, 2024
@hugovkhugovk removed the needs backport to 3.12only security fixes labelApr 10, 2025
@python-cla-bot
Copy link

python-cla-botbot commentedApr 18, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iritkatrieliritkatrieliritkatriel left review comments

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@furkanonderfurkanonderfurkanonder approved these changes

@serhiy-storchakaserhiy-storchakaAwaiting requested review from serhiy-storchaka

Assignees
No one assigned
Labels
awaiting changesdocsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixes
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

13 participants
@cjerdonek@serhiy-storchaka@JelleZijlstra@furkanonder@iritkatriel@AlexWaygood@ambv@hugovk@willingc@the-knights-who-say-ni@ezio-melotti@bedevere-bot@arhadthedev

[8]ページ先頭

©2009-2025 Movatter.jp