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-108082: Use PyErr_FormatUnraisable() by serhiy-storchaka · Pull Request #111580 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Oct 31, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().

  • Issue: [C API] Enhance PyErr_WriteUnraisable() API to pass an error message #108082

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka
pythongh-108082: Use PyErr_FormatUnraisable()
e126cd5
Replace most of calls of _PyErr_WriteUnraisableMsg() and some
calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().
@serhiy-storchaka serhiy-storchaka added the skip news label Oct 31, 2023
@serhiy-storchaka
serhiy-storchaka requested a review from vstinner October 31, 2023 22:33
@serhiy-storchaka
serhiy-storchaka requested review from iritkatriel, kumaraditya303, markshannon, methane and pablogsal as code owners October 31, 2023 22:33
@bedevere-app bedevere-app Bot mentioned this pull request Oct 31, 2023
[C API] Enhance PyErr_WriteUnraisable() API to pass an error message #108082
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 31, 2023
vstinner
vstinner reviewed Nov 1, 2023
View reviewed changes
Comment thread Modules/gcmodule.c Outdated
if (_PyErr_Occurred(tstate)) {
_PyErr_WriteUnraisableMsg("in tp_clear of",
(PyObject*)Py_TYPE(op));
PyErr_FormatUnraisable("Exception ignored in tp_clear of %.200s",

@vstinner vstinner Nov 1, 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.

IMO %.200s is a bug here. We should no longer truncate type names if they are too long. Many years ago, Python had an internal buffer of a fixed size and so the overall string must not be too long. But this has been fixed.

Please don't truncate type names.

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Modules/getpath.c Resolved

Uh oh!

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

Comment thread Modules/getpath.c Resolved

Uh oh!

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

Comment thread Objects/moduleobject.c Outdated
Comment on lines +905 to +907
PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V\n",
m->md_name ? " " : "",
m->md_name, "");

@vstinner vstinner Nov 1, 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.

Suggested change
PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V\n",
m->md_name ? " " : "",
m->md_name, "");
PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V",
m->md_name ? " " : "",
m->md_name);

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Objects/typeobject.c Outdated
PyType_WatchCallback cb = interp->type_watchers[i];
if (cb && (cb(type) < 0)) {
PyErr_WriteUnraisable((PyObject *)type);
PyErr_FormatUnraisable("Exception ignored in watcher callback for %R", i, type);

@vstinner vstinner Nov 1, 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.

If you want to log i variable, you should add %i somewhere.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/import.c Resolved

Uh oh!

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

Comment thread Python/perf_trampoline.c Resolved

Uh oh!

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

serhiy-storchaka and others added 5 commits November 1, 2023 09:31
@serhiy-storchaka @vstinner
Apply suggestions from code review
7e2a600
Co-authored-by: Victor Stinner <[email protected]>
@serhiy-storchaka
Merge branch 'main' into use-PyErr_FormatUnraisable
3a60137
@serhiy-storchaka
Fixes.
5f3b94a
@serhiy-storchaka
Fix test_cmd_line.
4f3292b
@serhiy-storchaka
Fix tests on Windows.
6445a4a
vstinner
vstinner approved these changes Nov 1, 2023
View reviewed changes

@vstinner vstinner 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 just left two minor suggestions.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Objects/moduleobject.c
PyErr_WriteUnraisable(NULL);
PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V",
m->md_name ? " " : "",
m->md_name, "");

@vstinner vstinner Nov 1, 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.

The last "" is not used, it can be removed.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Objects/typeobject.c Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Nov 1, 2023
serhiy-storchaka and others added 3 commits November 2, 2023 09:22
@serhiy-storchaka @vstinner
Update Objects/typeobject.c
331bcaf
Co-authored-by: Victor Stinner <[email protected]>
@serhiy-storchaka
Merge branch 'main' into use-PyErr_FormatUnraisable
c671f07
@serhiy-storchaka
Update tests.
4c15b7e
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) November 2, 2023 08:50
@serhiy-storchaka
serhiy-storchaka merged commit 970e719 into python:main Nov 2, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 2, 2023
@bedevere-bot

bedevere-bot commented Nov 2, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x Fedora Clang 3.x has failed when building commit 970e719.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/3/builds/4870) and take a look at the build logs.
  4. Check if the failure is related to this commit (970e719) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/3/builds/4870

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 53, done.        
remote: Counting objects:   1% (1/53)        
remote: Counting objects:   3% (2/53)        
remote: Counting objects:   5% (3/53)        
remote: Counting objects:   7% (4/53)        
remote: Counting objects:   9% (5/53)        
remote: Counting objects:  11% (6/53)        
remote: Counting objects:  13% (7/53)        
remote: Counting objects:  15% (8/53)        
remote: Counting objects:  16% (9/53)        
remote: Counting objects:  18% (10/53)        
remote: Counting objects:  20% (11/53)        
remote: Counting objects:  22% (12/53)        
remote: Counting objects:  24% (13/53)        
remote: Counting objects:  26% (14/53)        
remote: Counting objects:  28% (15/53)        
remote: Counting objects:  30% (16/53)        
remote: Counting objects:  32% (17/53)        
remote: Counting objects:  33% (18/53)        
remote: Counting objects:  35% (19/53)        
remote: Counting objects:  37% (20/53)        
remote: Counting objects:  39% (21/53)        
remote: Counting objects:  41% (22/53)        
remote: Counting objects:  43% (23/53)        
remote: Counting objects:  45% (24/53)        
remote: Counting objects:  47% (25/53)        
remote: Counting objects:  49% (26/53)        
remote: Counting objects:  50% (27/53)        
remote: Counting objects:  52% (28/53)        
remote: Counting objects:  54% (29/53)        
remote: Counting objects:  56% (30/53)        
remote: Counting objects:  58% (31/53)        
remote: Counting objects:  60% (32/53)        
remote: Counting objects:  62% (33/53)        
remote: Counting objects:  64% (34/53)        
remote: Counting objects:  66% (35/53)        
remote: Counting objects:  67% (36/53)        
remote: Counting objects:  69% (37/53)        
remote: Counting objects:  71% (38/53)        
remote: Counting objects:  73% (39/53)        
remote: Counting objects:  75% (40/53)        
remote: Counting objects:  77% (41/53)        
remote: Counting objects:  79% (42/53)        
remote: Counting objects:  81% (43/53)        
remote: Counting objects:  83% (44/53)        
remote: Counting objects:  84% (45/53)        
remote: Counting objects:  86% (46/53)        
remote: Counting objects:  88% (47/53)        
remote: Counting objects:  90% (48/53)        
remote: Counting objects:  92% (49/53)        
remote: Counting objects:  94% (50/53)        
remote: Counting objects:  96% (51/53)        
remote: Counting objects:  98% (52/53)        
remote: Counting objects: 100% (53/53)        
remote: Counting objects: 100% (53/53), done.        
remote: Compressing objects:   4% (1/25)        
remote: Compressing objects:   8% (2/25)        
remote: Compressing objects:  12% (3/25)        
remote: Compressing objects:  16% (4/25)        
remote: Compressing objects:  20% (5/25)        
remote: Compressing objects:  24% (6/25)        
remote: Compressing objects:  28% (7/25)        
remote: Compressing objects:  32% (8/25)        
remote: Compressing objects:  36% (9/25)        
remote: Compressing objects:  40% (10/25)        
remote: Compressing objects:  44% (11/25)        
remote: Compressing objects:  48% (12/25)        
remote: Compressing objects:  52% (13/25)        
remote: Compressing objects:  56% (14/25)        
remote: Compressing objects:  60% (15/25)        
remote: Compressing objects:  64% (16/25)        
remote: Compressing objects:  68% (17/25)        
remote: Compressing objects:  72% (18/25)        
remote: Compressing objects:  76% (19/25)        
remote: Compressing objects:  80% (20/25)        
remote: Compressing objects:  84% (21/25)        
remote: Compressing objects:  88% (22/25)        
remote: Compressing objects:  92% (23/25)        
remote: Compressing objects:  96% (24/25)        
remote: Compressing objects: 100% (25/25)        
remote: Compressing objects: 100% (25/25), done.        
remote: Total 27 (delta 26), reused 2 (delta 2), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '970e719a7a829bddc647bbaa668dd8603abdddef'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 970e719a7a gh-108082: Use PyErr_FormatUnraisable() (GH-111580)
Switched to and reset branch 'main'

configure: WARNING: s390x-ibm-linux-gnu/clang is not supported
configure: WARNING:

Platform "s390x-ibm-linux-gnu" with compiler "clang" is not supported by the
CPython core team, see https://peps.python.org/pep-0011/ for more information.


make: *** [Makefile:2065: buildbottest] Error 3
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Nov 2, 2023

Copy link
Copy Markdown
Member

I wanted to do this change for many years. It's awful to get a warning without any context :-( Thanks for this nice enhancement! I like PyErr_FormatUnraisable() API!

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka
serhiy-storchaka deleted the use-PyErr_FormatUnraisable branch November 2, 2023 11:12
@serhiy-storchaka

serhiy-storchaka commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

We both wanted it. But other tasks had higher priorities.

vstinner reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

FullteaR pushed a commit to FullteaR/cpython that referenced this pull request Nov 3, 2023
@serhiy-storchaka @vstinner @FullteaR
pythongh-108082: Use PyErr_FormatUnraisable() (pythonGH-111580)
a6f4f43
Replace most of calls of _PyErr_WriteUnraisableMsg() and some
calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().

Co-authored-by: Victor Stinner <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@serhiy-storchaka @vstinner @aisk
pythongh-108082: Use PyErr_FormatUnraisable() (pythonGH-111580)
daf14e8
Replace most of calls of _PyErr_WriteUnraisableMsg() and some
calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().

Co-authored-by: Victor Stinner <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@serhiy-storchaka @vstinner @Glyphack
pythongh-108082: Use PyErr_FormatUnraisable() (pythonGH-111580)
56133ef
Replace most of calls of _PyErr_WriteUnraisableMsg() and some
calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().

Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@iritkatriel iritkatriel Awaiting requested review from iritkatriel iritkatriel 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

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@serhiy-storchaka @bedevere-bot @vstinner
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.