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

gh-116307: Proper fix for 'mod' leaking across importlib tests #116680

Merged
merged 1 commit into from Mar 12, 2024

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Mar 12, 2024

As discovered in #116307 (comment), addresses an issue in importlib.resources tests where a module imported for test can leak to other tests.

…e that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

@jaraco jaraco merged commit a254807 into python:main Mar 12, 2024
38 checks passed
@miss-islington-app
Copy link

Thanks @jaraco for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 12, 2024
…ythonGH-116680)

(cherry picked from commit a254807)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
@miss-islington-app
Copy link

Sorry, @jaraco, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker a2548077614f81f25a2c3465dabb7a0a3885c40c 3.11

@bedevere-app
Copy link

bedevere-app bot commented Mar 12, 2024

GH-116684 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Mar 12, 2024
@jaraco jaraco deleted the ghpython-116307/safe-site-dir-standalone branch March 12, 2024 23:33
pablogsal pushed a commit to pablogsal/cpython that referenced this pull request Mar 12, 2024
… tests (pythonGH-116680) (python#116684)

pythongh-116307: Proper fix for 'mod' leaking across importlib tests (pythonGH-116680)
(cherry picked from commit a254807)


pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 13, 2024

GH-116694 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Mar 13, 2024
jaraco added a commit that referenced this pull request Mar 13, 2024
#116694)

[3.11] gh-116307: Proper fix for 'mod' leaking across importlib tests (GH-116680)
(cherry picked from commit a254807)


gh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
jaraco added a commit to jaraco/cpython that referenced this pull request Mar 13, 2024
… tests (pythonGH-116680)

(cherry picked from commit a254807)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
@encukou
Copy link
Member

encukou commented Mar 13, 2024

Ironically, since this was merged, test_importlib started leaking on refleaks buildbots.

@vstinner
Copy link
Member

Example of leak:

$ ./python -m test test_importlib -R 3:3 -m test_requires_egg_info_empty
Using random seed: 1080788092
0:00:00 load avg: 1.15 Run 1 test sequentially
0:00:00 load avg: 1.15 [1/1] test_importlib
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XXX XXX
test_importlib leaked [116, 116, 116] references, sum=348
test_importlib leaked [78, 78, 78] memory blocks, sum=234
test_importlib failed (reference leak)

== Tests result: FAILURE ==

1 test failed:
    test_importlib

Total duration: 2.0 sec
Total tests: run=1 (filtered)
Total test files: run=1/1 (filtered) failed=1
Result: FAILURE

vstinner pushed a commit to vstinner/cpython that referenced this pull request Mar 20, 2024
…ython#116680)

pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…ython#116680)

pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…ython#116680)

pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants