GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-101578: Normalize the current exception by markshannon · Pull Request #101607 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Feb 6, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is a necessary step for implementing PEP 669, as instrumentation needs exceptions to be normalized.

Also fixes #101578.

  • Issue: PyErr_SetObject() behavior is strange and not as documented. #101578

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
markshannon added 5 commits February 6, 2023 14:11
@markshannon
Make sure that the current exception is always normalized.
87889bc
@markshannon
Remove redundant type and traceback fields for the current exception.
14f21ff
@markshannon
Replace a some uses of PyErr_Fetch with PyErr_Fetch1.
8b62323
@markshannon
Refactor assertion.
508850f
@markshannon
Document new C-API functions
073409a
@markshannon
markshannon requested review from brettcannon, encukou, ericsnowcurrently, iritkatriel, lysnikolaou, methane, ncoghlan, pablogsal and warsaw as code owners February 6, 2023 16:10
@bedevere-bot bedevere-bot added the awaiting core review label Feb 6, 2023
@bedevere-bot bedevere-bot mentioned this pull request Feb 6, 2023
PyErr_SetObject() behavior is strange and not as documented. #101578
Closed
markshannon added 2 commits February 6, 2023 16:14
@markshannon
Add news
d260b13
@markshannon
Fix typos
d5480e9
iritkatriel
iritkatriel reviewed Feb 6, 2023
View reviewed changes
Comment thread Doc/c-api/exceptions.rst Outdated

.. c:function:: void PyErr_Restore1(PyObject *exc)

As of 3.12, this function is deprecated. Use :c:func:`PyErr_Restore1` instead.

@iritkatriel iritkatriel Feb 6, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

?? this is PyErr_Restore1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/c-api/exceptions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/c-api/exceptions.rst Outdated

As of 3.12, this function is deprecated. Use :c:func:`PyErr_Restore1` instead.

Set the error indicator to ``exc``.

@iritkatriel iritkatriel Feb 6, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This looks like it's in the wrong place.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
markshannon added 4 commits February 6, 2023 18:30
@markshannon
Update generated code.
0c3dc7b
@markshannon
Rename new functions and fix up docs.
aa70bad
@markshannon
Fix up news entry
1ae8eda
@markshannon
Update stable ABI.
fe6c34f
@markshannon
markshannon requested a review from a team as a code owner February 7, 2023 12:43
iritkatriel
iritkatriel reviewed Feb 7, 2023
View reviewed changes
Comment thread Include/internal/pycore_pyerrors.h
PyObject *exc);

void
_PyErr_SetRaisedException(PyThreadState *tstate, PyObject *exc);

@iritkatriel iritkatriel Feb 7, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

does this need "extern" too?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/errors.c
void
_PyErr_Restore(PyThreadState *tstate, PyObject *type, PyObject *value,
PyObject *traceback)
{

@iritkatriel iritkatriel Feb 7, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don't think it's currently a requirement to pass in only normalised exceptions. This could break C extensions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@markshannon markshannon Feb 7, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'll add some extra logic. It will slow things down a bit, but safety first.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iritkatriel iritkatriel Feb 7, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe you could make _PyErr_Restore to expectonly normalised exceptions, but normalise them in PyErr_Restore?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon markshannon closed this Feb 7, 2023
@markshannon markshannon reopened this Feb 7, 2023
@markshannon
Restore behavior of PyErr_Restore, and add tests.
566f6e1
iritkatriel
iritkatriel approved these changes Feb 7, 2023
View reviewed changes

@iritkatriel iritkatriel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. I'd run tests with the buildbots before merging though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot removed the awaiting core review label Feb 7, 2023
@bedevere-bot bedevere-bot added the awaiting merge label Feb 7, 2023
@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 7, 2023
@bedevere-bot

bedevere-bot commented Feb 7, 2023

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @markshannon for commit 566f6e1 🤖

If you want to schedule another build, you need to add the :hammer: test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 7, 2023
@markshannon
Fix refleaks
99f0880
@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 7, 2023
@bedevere-bot

bedevere-bot commented Feb 7, 2023

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @markshannon for commit 99f0880 🤖

If you want to schedule another build, you need to add the :hammer: test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 7, 2023
@markshannon

markshannon commented Feb 8, 2023

Copy link
Copy Markdown
Member Author

The buildbot/PPC64LE RHEL8 Refleaks PR failure seems unrelated (the other refleak buildbots all pass) and that buildbot seems a bit flaky.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon
markshannon merged commit feec49c into python:main Feb 8, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Feb 8, 2023
@markshannon
markshannon deleted the normalize-current-exception branch February 8, 2023 09:31
carljm added a commit to carljm/cpython that referenced this pull request Feb 9, 2023
@carljm
Merge branch 'main' into inlinecomp2
be3becc
* main: (82 commits)
  pythongh-101670: typo fix in PyImport_ExtendInittab() (python#101723)
  pythonGH-99293: Document that `Py_TPFLAGS_VALID_VERSION_TAG` shouldn't be used. (#pythonGH-101736)
  no-issue: Add Dong-hee Na as the cjkcodecs codeowner (pythongh-101731)
  pythongh-101678: Merge math_1_to_whatever() and math_1() (python#101730)
  pythongh-101678: refactor the math module to use special functions from c11 (pythonGH-101679)
  pythongh-85984: Remove legacy Lib/pty.py code. (python#92365)
  pythongh-98831: Use opcode metadata for stack_effect() (python#101704)
  pythongh-101283: Version was just released, so should be changed in 3.11.3 (pythonGH-101719)
  pythongh-101283: Fix use of unbound variable (pythonGH-101712)
  pythongh-101283: Improved fallback logic for subprocess with shell=True on Windows (pythonGH-101286)
  pythongh-101277: Port more itertools static types to heap types (python#101304)
  pythongh-98831: Modernize CALL and family (python#101508)
  pythonGH-101696: invalidate type version tag in `_PyStaticType_Dealloc` (python#101697)
  pythongh-100221: Fix creating dirs in `make sharedinstall` (pythonGH-100329)
  pythongh-101670: typo fix in PyImport_AppendInittab() (pythonGH-101672)
  pythongh-101196: Make isdir/isfile/exists faster on Windows (pythonGH-101324)
  pythongh-101614: Don't treat python3_d.dll as a Python DLL when checking extension modules for incompatibility (pythonGH-101615)
  pythongh-100933: Improve `check_element` helper in `test_xml_etree` (python#100934)
  pythonGH-101578: Normalize the current exception (pythonGH-101607)
  pythongh-47937: Note that Popen attributes are read-only (python#93070)
  ...
@erlend-aasland erlend-aasland mentioned this pull request Feb 17, 2023
gh-101578: Amend PyErr_{Set,Get}RaisedException docs #101962
Merged
@CAM-Gerlach CAM-Gerlach mentioned this pull request Feb 19, 2023
gh-101578: Amend exception docs #102057
Merged
@tacaswell tacaswell mentioned this pull request Mar 1, 2023
[BUG] Fast thread state access is broken by Py3.12a6 cython/cython#5286
Closed
@ned-deily ned-deily mentioned this pull request Mar 7, 2023
gh-101607 causes regression in third-party psutil package on macOS #102493
Closed
@iritkatriel iritkatriel mentioned this pull request Mar 13, 2023
Suspected PyErr_Fetch() behavior change #102594
Closed
@brianschubert brianschubert mentioned this pull request May 7, 2025
sys.exit unpacks its argument if it is a 0- or 1-element tuple #133548
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@encukou encukou Awaiting requested review from encukou encukou is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner
@methane methane Awaiting requested review from methane methane is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PyErr_SetObject() behavior is strange and not as documented.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@markshannon @bedevere-bot @iritkatriel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.