-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PEP-654: add example of subgroup callback with side effects #1852
Conversation
|
||
.. code-block:: | ||
|
||
def leaf_generator(exc, tbs=None): |
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 we could show a little code fragment that uses this as well? It would have to include at least
try:
. . .
except *OSError as eg:
for exc, tbs in leaf_generator(eg):
if exc.errno != ENOENT:
print(exc)
<show how to print the traceback using the traceback module>
I think the last line would have to call extract_tb() for each item of tbs, concatenate the lists (in which order?), and then call print_list() on the concatenation. I'm too lazy to research how exactly.
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.
Strange, the two minor fixups I applied came back. Also, there are two spaces missing from the output. Is the code correct?
Otherwise LG.
pep-0654.rst
Outdated
File "<stdin>", line 3, in g | ||
ValueError: 1 | ||
The complete traceback for Exception #1 | ||
File "<stdin>", line 2, in <module> |
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.
File "<stdin>", line 2, in <module> | |
File "<stdin>", line 2, in <module> |
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.
let me check this
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.
Yeah the code gives it indented. I messed it up in the copy-paste.
Co-authored-by: Guido van Rossum <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
... eg = e | ||
... | ||
>>> for (i, (exc, tbs)) in enumerate(leaf_generator(eg)): | ||
... print(f"\n>>> Exception #{i+1}:") |
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.
">>>" was a poor choice here, it gets mixed up with the interactive prompt. I'll replace it.
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.
Sorry, I already merged. Awaiting your next PR...
No description provided.