-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
test_pickle/test_pickletools fail when running tests sequentially. #103247
Comments
The problem is actually reproducible all the way back to 3.12.0a4, even though it was never caught in the release testing (I don't know why, yet). The problem was exposed by #100142, but that merely adds testing of picklability of builtins, which all things considered is not an unreasonable test. |
As it appears this is merely uncovering a long standing issue with a hole in subinterpreter isolation and importlib (the same test combination fails in 3.10 and 3.11), I'm unblocking a7 for now, but leaving this as a release blocker for beta 1. |
I did some bisecting in 3.10 and 3.11, and it landed like this:
Strangely, I do not get the same result in The linked issues for those PRs contain some interesting history and debugging:
(It would be nice if someone else could bisect on their machine and verify my findings.) |
Is it because the release testing in running in 4 processes? |
No, the release testing is done sequentially, and that hasn't changed in 2 years: https://github.com/python/release-tools/blame/master/run_release.py#L486 |
Just some research for others also looking into it. The failure comes from cpython/Lib/test/pickletester.py Lines 1985 to 1990 in fd1947e
I suspect the issue is simply that cpython/Lib/test/test_importlib/util.py Lines 52 to 53 in 52bc2e7
The deal with I think this is simply caused by leakage of the importlib tests, and has nothing to do with subinterpreters. |
I am testing on with macos 13.3 clang 14
FWIW, I discovered that, test_importlib has many submodules. You can invoke test as
with different We got a map from {
"test_importlib.builtin.test_finder": 2,
"test_importlib.builtin.test_loader": 2,
"test_importlib.extension.test_case_sensitivity": 2,
"test_importlib.extension.test_finder": 2,
"test_importlib.extension.test_loader": 2,
"test_importlib.frozen.test_finder": 2,
"test_importlib.frozen.test_loader": 2,
"test_importlib.import_.test___loader__": 2,
"test_importlib.import_.test___package__": 2,
"test_importlib.import_.test_api": 2,
"test_importlib.import_.test_caching": 2,
"test_importlib.import_.test_fromlist": 2,
"test_importlib.import_.test_helpers": 2,
"test_importlib.import_.test_meta_path": 2,
"test_importlib.import_.test_packages": 2,
"test_importlib.import_.test_path": 2,
"test_importlib.import_.test_relative_imports": 2,
"test_importlib.resources.test_compatibilty_files": 0,
"test_importlib.resources.test_contents": 0,
"test_importlib.resources.test_files": 0,
"test_importlib.resources.test_open": 0,
"test_importlib.resources.test_path": 0,
"test_importlib.resources.test_read": 0,
"test_importlib.resources.test_reader": 0,
"test_importlib.resources.test_resource": 0,
"test_importlib.source.test_case_sensitivity": 2,
"test_importlib.source.test_finder": 2,
"test_importlib.source.test_source_encoding": 2,
"test_importlib.test_abc": 2,
"test_importlib.test_api": 2,
"test_importlib.test_lazy": 2,
"test_importlib.test_locks": 2,
"test_importlib.test_main": 0,
"test_importlib.test_metadata_api": 0,
"test_importlib.test_namespace_pkgs": 2,
"test_importlib.test_pkg_import": 0,
"test_importlib.test_spec": 2,
"test_importlib.test_threaded_import": 0,
"test_importlib.test_util": 2,
"test_importlib.test_zip": 0,
} |
Looks like "those files that returned code 2" all import Hope it is helpful. |
FWIW, at the very least we should skip the module-specific dunder names ( That said, we should also make sure there's a test somewhere that catches the reported failure (which we happened to get lucky catching in the pickle tests).
+1 (but worth verifying)
+1 (but worth verifying) |
|
This is not a fix for the importlib test monkeypatching leakage but it's something that we probably should be doing anyway. Signed-off-by: Filipe Laíns <lains@riseup.net>
I looked into it. The failure (changing the env) comes from cpython/Lib/test/test_importlib/extension/test_loader.py Lines 263 to 273 in e5b8b19
Commenting on it solves this issue. It seems not to follow the |
Good catch! Do you want to open a PR with the fix? I think it'd make sense to add a teardown method which unloads |
|
…xtensions/test_loader.py (pythonGH-104226) (cherry picked from commit 22f3425) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
* main: pythonGH-102181: Improve specialization stats for SEND (pythonGH-102182) pythongh-103000: Optimise `dataclasses.asdict` for the common case (python#104364) pythongh-103538: Remove unused TK_AQUA code (pythonGH-103539) pythonGH-87695: Fix OSError from `pathlib.Path.glob()` (pythonGH-104292) pythongh-104263: Rely on Py_NAN and introduce Py_INFINITY (pythonGH-104202) pythongh-104010: Separate and improve docs for `typing.get_origin` and `typing.get_args` (python#104013) pythongh-101819: Adapt _io._BufferedIOBase_Type methods to Argument Clinic (python#104355) pythongh-103960: Dark mode: invert image brightness (python#103983) pythongh-104252: Immortalize Py_EMPTY_KEYS (pythongh-104253) pythongh-101819: Clean up _io windows console io after pythongh-104197 (python#104354) pythongh-101819: Harden _io init (python#104352) pythongh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (pythonGH-104226) pythongh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (python#103849) pythongh-74895: adjust tests to work on Solaris (python#104326) pythongh-101819: Refactor _io in preparation for module isolation (python#104334) pythongh-90953: Don't use deprecated AST nodes in clinic.py (python#104322) pythongh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request() pythongh-104328: Fix typo in ``typing.Generic`` multiple inheritance error message (python#104335)
When running the test suite sequentially (as is done as part of the release process), an interaction between test_imp, test_importlib and subinterpreters is causing test_pickle and test_pickletools to fail. The easiest reproducer::
The failure happens in both test_pickle and test_pickletools (test_pickletools's traceback is more obvious), after in the same process running both test_imp and either test_import or test_importlib. Disabling
test_imp.ImportTests.test_create_builtin_subinterp()
makes the tests pass. (This was happening before #102982 as well as after it, so I don't think it is involved here.)I expect this is an unintentional side-effect of the test, but this was not happening in the 3.12.0a6 release, and as far as I can tell the relevant tests haven't changed since before a6. I'm delaying the 3.12.0a7 release until it's clear this isn't a fundamental problem with subinterpreters.
Linked PRs
tearDown
totest_loader
and clear module cache #104226The text was updated successfully, but these errors were encountered: