Skip to content
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

synthesize a traceback to get a normal exc_info from an exception #12187

Merged
merged 5 commits into from
Jul 30, 2023

Conversation

cosmicexplorer
Copy link
Contributor

@cosmicexplorer cosmicexplorer commented Jul 28, 2023

Problem

main is currently broken on 3.12:

> nox -e test-3.12 -- -k test_tempdir_cleanup_ignore_errors
...
FAILED tests/unit/test_utils_temp_dir.py::test_tempdir_cleanup_ignore_errors - TypeError: 'PermissionError' object is not subscriptable

While it seems like #11394 may have been the direct trigger for the test failure, it appears the error was first introduced earlier in a hasty attempt to remove some DeprecationWarnings (25f4e6e). It turns out that while the documentation at https://docs.python.org/3.12/library/shutil.html#shutil.rmtree still uses the name "excinfo" for the third argument to onexc, onexc actually has a BaseException for the third argument instead of a sys.exc_info(), as per https://docs.python.org/3.12/whatsnew/3.12.html#shutil.

Solution

  • Since we don't use the sys.exc_info() parts anywhere, just convert any sys.exc_info() to a BaseException in our callback wrapper, and switch to explicitly only handling BaseException in our error callbacks.

- as per https://docs.python.org/3.12/whatsnew/3.12.html#shutil, we must expect only an exception
  and *not* the full exc_info from the new onexc function (the documentation of this is very
  misleading and still uses the label "excinfo":
  https://docs.python.org/3.12/library/shutil.html#shutil.rmtree)
news/12187.bugfix.rst Outdated Show resolved Hide resolved
@uranusjr uranusjr merged commit b69ed81 into pypa:main Jul 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants