bpo-26389: Allow traceback function to only get an exception instance (instead of 3 args) by Carreau · Pull Request #327 · python/cpython · GitHub
Skip to content

bpo-26389: Allow traceback function to only get an exception instance (instead of 3 args) - #327

Closed
Carreau wants to merge 1 commit into
python:masterfrom
Carreau:traceb
Closed

Carreau wants to merge 1 commit into
python:masterfrom
Carreau:traceb

Conversation

@Carreau

@Carreau Carreau commented Feb 27, 2017

Copy link
Copy Markdown
Contributor

Instead of having to pass type/value/tb separately, allow to pass
exc=ExceptionInstance()

Instead of having to pass type/value/tb separately, allow to pass
`exc=ExceptionInstance()`
@terryjreedy

Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You must document these changes in Doc/library/traceback.rst. Don't forget a ".. versionchanged:: 3.7" section.

Comment thread Lib/traceback.py

Since python 3.7, instead of passing *etype*, *value* and *tb* separately,
it is recommended to use the *exc* keyword argument which will infer all the
required values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should also document that the traceback object is now get from exc if tb is not set.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this would be better off in the main RST documentation, rather than the doc strings. Normally the doc strings exclude finer details, changes from previous versions, etc.

Comment thread Lib/traceback.py

Since python 3.7, instead of passing *etype*, *value* and *tb* separately,
it is recommended to use the *exc* keyword argument which will infer all the
required values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Comment thread Lib/traceback.py

Since python 3.7, instead of passing *etype* and *value* separately, it is
recommended to use the *exc* keyword argument which will infer all the
required values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Comment thread Lib/traceback.py
elif exc:
value = exc
tb = exc.__traceback__
etype = type(value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like these lines are duplicated 3 times: write a private helper function to factorize the code.

@vstinner vstinner changed the title bpo-26389: Allow some function in traceback to take instances. bpo-26389: Allow traceback function to only get an exception instance (instead of 3 args) Mar 2, 2017
@vstinner vstinner added the type-feature A feature request or enhancement label Mar 2, 2017
Comment thread Lib/traceback.py
occurred with a caret on the next line indicating the approximate
position of the error.

The *etype* parameter is ignored since python 3.5 and get inferred from

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

gets inferred

Comment thread Lib/traceback.py
*value*.

Since python 3.7, instead of passing *etype*, *value* and *tb* separately,
it is recommended to use the *exc* keyword argument which will infer all the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is recommended to use the exc keyword argument, which [specifies] all the required values.

Comment thread Lib/traceback.py

Since python 3.7, instead of passing *etype*, *value* and *tb* separately,
it is recommended to use the *exc* keyword argument which will infer all the
required values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this would be better off in the main RST documentation, rather than the doc strings. Normally the doc strings exclude finer details, changes from previous versions, etc.

@Carreau

Carreau commented Mar 2, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I think I'll restart that from scratch and use the approach describe in https://bugs.python.org/issue26389, basically using etype to extract type/value/tb by still keeping old call possible.

@terryjreedy

Copy link
Copy Markdown
Member

using etype to extract ...
I am not sure what you mean, but etype should continue to be ignored as it is today. I think it premature to work more on a patch until we agree on the API, as I discussed on the issue.

@terryjreedy
terryjreedy self-requested a review March 3, 2017 04:51

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait until API decided on.

@brettcannon

Copy link
Copy Markdown
Member

@Carreau Carreau closed this May 27, 2020
klange pushed a commit to toaruos/cpython that referenced this pull request Sep 15, 2021
jaraco pushed a commit that referenced this pull request Dec 2, 2022
Bumps [cachetools](https://github.com/tkem/cachetools) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/tkem/cachetools/releases)
- [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
- [Commits](tkem/cachetools@v4.0.0...v4.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
@Carreau
Carreau deleted the traceb branch October 20, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants