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 — bpo-45711: use exc_value instead of exc_type to determine if exc_info is valid. Add more assertions. by iritkatriel · Pull Request #29627 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Nov 18, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This brings us closer to removing exc_type from exc_info.

Where exc_type is used, I made it use exc_value instead and added assertions that this is ok. Then when we remove exc_type it will just be a matter of removing the assertions.

https://bugs.python.org/issue45711

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel
bpo-45711: make decisions based on exc_value instead of exc_type. Str…
9275583
…engthen redundancy assertion for NULL/None.
@iritkatriel
iritkatriel requested a review from markshannon as a code owner November 18, 2021 19:25
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Nov 18, 2021
@bedevere-bot bedevere-bot added the awaiting core review label Nov 18, 2021
@iritkatriel iritkatriel added the skip news label Nov 18, 2021
@iritkatriel
iritkatriel requested a review from terryjreedy November 18, 2021 19:54
iritkatriel added 2 commits November 19, 2021 10:38
@iritkatriel
put assertion definition under Py_DEBUG to remove Address sanitizer w…
fbff4f6
…arning
@iritkatriel
Merge remote-tracking branch 'upstream/main' into bpo-45711-remove-ex…
bc889bc
…c_type_field
@iritkatriel iritkatriel added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 22, 2021
@bedevere-bot

bedevere-bot commented Nov 22, 2021

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit bc889bc 🤖

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 Nov 22, 2021
@iritkatriel
iritkatriel requested a review from gvanrossum November 23, 2021 11:02
gvanrossum
gvanrossum reviewed Nov 24, 2021
View reviewed changes

@gvanrossum gvanrossum 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.

I noticed that in some places you require type and value to be both "nullish" or both "not nullish" (where "nullish" means either NULL or Py_None), and in other places (in particular in _assert_exception_type_is_redundant()) they are required to both be the same nullishness (i.e., both NULL or both Py_None or neither of them nullish). Is there a reason for the difference?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/errors.c Resolved

Uh oh!

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

@iritkatriel @gvanrossum
err_info->exc_value ==> exc_value
3c451a1
Co-authored-by: Guido van Rossum <[email protected]>
@iritkatriel

iritkatriel commented Nov 24, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I noticed that in some places you require type and value to be both "nullish" or both "not nullish" (where "nullish" means either NULL or Py_None), and in other places (in particular in _assert_exception_type_is_redundant()) they are required to both be the same nullishness (i.e., both NULL or both Py_None or neither of them nullish). Is there a reason for the difference?

Yes. Most of these assertions are verifying that the change right next to them is valid. So if I replace if(exc_type is nullish) by if(exc_value is nullish) then I only care that their nullishness is the same. In the case of the triplets pushed to the stack, it used to be that no-exc was pushed as "NULL, NULL, None" (None for type, NULL for value and tb). I change that in this PR (ceval.c lines 5907-9 sorry - 4182-88) so now it's "NULL, None, None". There are places where "None at the top of the stack" means there is no exc_info. So when we will remove the type we need the value to be None and not NULL, otherwise we'll get segfaults.

gvanrossum reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

gvanrossum
gvanrossum reviewed Nov 24, 2021
View reviewed changes

@gvanrossum gvanrossum 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.

Okay, I'm through now. (Sorry for the premature send on the first batch.)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/errors.c Resolved

Uh oh!

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

Comment thread Python/errors.c Resolved

Uh oh!

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

Comment thread Python/errors.c Resolved

Uh oh!

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

Comment thread Python/errors.c Outdated
@@ -586,7 +633,18 @@ _PyErr_ChainStackItem(_PyErr_StackItem *exc_info)
exc2 = exc_info->exc_type;

@gvanrossum gvanrossum Nov 24, 2021

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.

While you're here could you change 'exc' and 'exc2' to 'type' and 'type2' (or 'typ' and 'typ2')? It drives me nuts that we mix "exc[exption]" and "typ[e]" for the same concept (this must date back to Python 1 when the value was not an exception instance and the exception could be any object).

Sorry, something went wrong.

Uh oh!

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

iritkatriel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
iritkatriel added 3 commits November 24, 2021 23:50
@iritkatriel
Simplified _PyErr_GetExcInfo. Moved assertion in _PyErr_GetTopmostExc…
277c509
…eption.
@iritkatriel
exc2 --> typ2
437cebb
@iritkatriel
exc --> typ
de67ed6
gvanrossum
gvanrossum approved these changes Nov 25, 2021
View reviewed changes

@gvanrossum gvanrossum 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.

All good! (Alas, I'm still stuck trying to wrap my head around the except* implementation, so that one will probably have to wait until next week.)

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Nov 25, 2021
@iritkatriel
iritkatriel merged commit c456dfa into python:main Nov 25, 2021
@bedevere-bot bedevere-bot removed the awaiting merge label Nov 25, 2021
remykarem pushed a commit to remykarem/cpython that referenced this pull request Dec 7, 2021
@iritkatriel remykarem
bpo-45711: use exc_value instead of exc_type to determine if exc_info…
c69c987
… is valid. Add more assertions. (pythonGH-29627)
@iritkatriel
iritkatriel deleted the bpo-45711-remove-exc_type_field branch January 13, 2022 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@terryjreedy terryjreedy Awaiting requested review from terryjreedy

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.

4 participants

@iritkatriel @bedevere-bot @gvanrossum @the-knights-who-say-ni
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.