-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-26389: Allow traceback function to only get an exception instance (instead of 3 args) #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Instead of having to pass type/value/tb separately, allow to pass `exc=ExceptionInstance()`
|
-1 on the patch as is. I posted my analysis and suggestions in msg288671 in https://bugs.python.org/issue26389. In brief, 'exc' and 'value' should be synonyms until 'value' is deleted, and 'tb' parameter should be kept with tb=True the default and meaning 'get tb from exc'. I consider the latter more important and the name change and 'etype' deletion. |
vstinner
left a comment
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.
You must document these changes in Doc/library/traceback.rst. Don't forget a ".. versionchanged:: 3.7" section.
| 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. |
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.
You should also document that the traceback object is now get from exc if tb is not set.
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 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.
| 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. |
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.
ditto
| 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. |
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.
ditto
| elif exc: | ||
| value = exc | ||
| tb = exc.__traceback__ | ||
| etype = type(value) |
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.
It seems like these lines are duplicated 3 times: write a private helper function to factorize the code.
| 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 |
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.
gets inferred
| *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 |
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.
it is recommended to use the exc keyword argument, which [specifies] all the required values.
| 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. |
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 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.
|
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 |
|
terryjreedy
left a comment
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.
Wait until API decided on.
|
To try and help move older pull requests forward, we are going through and backfilling 'awaiting' labels on pull requests that are lacking the label. Based on the current reviews, the best we can tell in an automated fashion is that a core developer requested changes to be made to this pull request. If/when the requested changes have been made, please leave a comment that says, |
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] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Instead of having to pass type/value/tb separately, allow to pass
exc=ExceptionInstance()