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-111922: Allow Using a Minimal Proxy for TracebackException.exc_type by ericsnowcurrently · Pull Request #112324 · python/cpython

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Nov 22, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Passing a proxy for exc_type is helpful when the TracebackException is going to be serialized (e.g. pickle) and you don't want to serialize user-defined types.

(That's the concrete motivation for me. For the _xxsubinterpreters module I'm propagating exceptions via a pickled TracebackException and don't want to deal with unpickling a user-defined exception class in a different interpreter.)

Note that most of this PR is tests, including a bunch of coverage of existing behavior.

  • Issue: Support Passing a Proxy object to traceback.TracebackExcetion() for "exc_type" #111922

Sorry, something went wrong.

Uh oh!

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

All reactions
ericsnowcurrently added 6 commits November 17, 2023 15:56
@ericsnowcurrently
Add tests for TracebackException.exc_type.
2fd3f1e
@ericsnowcurrently
Factor out _match_class().
d58e089
@ericsnowcurrently
Factor out _resolve_exc_type().
f862c4e
@ericsnowcurrently
Honor proxies.
9209b15
@ericsnowcurrently
Drop tests for str.
42a4904
@ericsnowcurrently
Add a NEWS entry.
f7c61b2
@ericsnowcurrently
ericsnowcurrently requested a review from iritkatriel as a code owner November 22, 2023 21:48
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 22, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 22, 2023
Support Passing a Proxy object to traceback.TracebackExcetion() for "exc_type" #111922
Closed
iritkatriel
iritkatriel reviewed Nov 22, 2023
View reviewed changes
Comment thread Lib/test/test_traceback.py
self.addCleanup(sys.path.pop)

if not mod_name:
mod_name = ''.join(random.choices(string.ascii_letters, k=16))

@iritkatriel iritkatriel Nov 22, 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 assert that mod_name is not in sys.modules before we add it?

Sorry, something went wrong.

Uh oh!

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

ericsnowcurrently reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/test/test_traceback.py Outdated
def __repr__(self) -> str:
raise Exception("Unrepresentable")


@iritkatriel iritkatriel Nov 22, 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

Sorry, something went wrong.

Uh oh!

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

ericsnowcurrently reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
iritkatriel
iritkatriel reviewed Nov 22, 2023
View reviewed changes
Comment thread Lib/traceback.py Outdated
raise ValueError(f'unsupported exc_type {exc_type!r}')


def _match_class(exc_type, *expected):

@iritkatriel iritkatriel Nov 22, 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.

nit: I'd pass expected as a tuple (single arg), same way that types are passed to isinstance, etc.

Sorry, something went wrong.

Uh oh!

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

ericsnowcurrently reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@ericsnowcurrently
Address review comments.
04a6d8e
@ericsnowcurrently
ericsnowcurrently requested a review from iritkatriel November 23, 2023 00:49
@ericsnowcurrently

ericsnowcurrently commented Nov 28, 2023

Copy link
Copy Markdown
Member Author

I'm closing this in favor of gh-112333.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ericsnowcurrently ericsnowcurrently closed this Nov 28, 2023
@ericsnowcurrently
ericsnowcurrently deleted the traceback-support-exc_type-proxy branch November 28, 2023 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel Awaiting requested review from iritkatriel

Uh oh!

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

Assignees

No one assigned

Labels

awaiting core review

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.

2 participants

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