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_inspect fails in refleak mode #88971
Comments
From https://bugs.python.org/issue44206 : File "/home/mark/repos/cpython/Lib/inspect.py", line 1154, in walktree I can reproduce that failure with a debug build and either of |
I'm bisecting |
f468ede is the first bad commit
Lib/inspect.py | 2 ++ |
The reason buildbots have not catched this is because the re-run login seems to not detect the problem on the second run: ./python.exe -m test test_inspect -j 1 -u all -W --slowest --fail-env-changed --timeout=11700 -R 3:3 -u-cpu -w WARNING: Disable --verbose3 because it's incompatible with --huntrleaks: see http://bugs.python.org/issue27103
0:00:00 load avg: 2.73 Run tests in parallel using 1 child processes (timeout: 3 hour 15 min, worker timeout: 3 hour 20 min)
0:00:03 load avg: 2.92 [1/1/1] test_inspect failed (1 error)
beginning 6 repetitions
123456
.test test_inspect failed -- Traceback (most recent call last):
File "/Users/pgalindo3/github/cpython/Lib/test/test_inspect.py", line 398, in test_getclasses
tree = inspect.getclasstree([cls[1] for cls in classes])
File "/Users/pgalindo3/github/cpython/Lib/inspect.py", line 1185, in getclasstree
return walktree(roots, children, None)
File "/Users/pgalindo3/github/cpython/Lib/inspect.py", line 1158, in walktree
results.append(walktree(children[c], children, c))
File "/Users/pgalindo3/github/cpython/Lib/inspect.py", line 1154, in walktree
classes.sort(key=attrgetter('__module__', '__name__'))
TypeError: '<' not supported between instances of 'str' and 'module' == Tests result: FAILURE == 10 slowest tests:
1 test failed: 1 re-run test: 0:00:03 load avg: 2.92 Re-running failed tests in verbose mode ---------------------------------------------------------------------- Ran 1 test in 0.001s OK ---------------------------------------------------------------------- Ran 1 test in 0.001s OK ---------------------------------------------------------------------- Ran 1 test in 0.001s OK ---------------------------------------------------------------------- Ran 1 test in 0.001s OK ---------------------------------------------------------------------- Ran 1 test in 0.001s OK ---------------------------------------------------------------------- Ran 1 test in 0.001s OK == Tests result: FAILURE then SUCCESS == 1 test OK. 10 slowest tests:
Total duration: 4.6 sec |
Check for instance the logs in https://buildbot.python.org/all/#/builders/679/builds/92/steps/5/logs/stdio |
From f468ede: This code looks quite dangerous: class TestGetsourceInteractive(unittest.TestCase):
def tearDown(self):
mod.ParrotDroppings.__module__ = mod
sys.modules['__main__'] = self.main That is modifing sys.modules globally! |
Ah, the problem is that: mod.ParrotDroppings.__module__ = mod is wrong: |
PR 27544 just addresses the main problem, but I still have concerns about the test affecting sys.modules directly, making it dangerous to run in parallel. |
With PR 27544: ❯ ./python.exe -m test test_inspect -R : == Tests result: SUCCESS == 1 test OK. Total duration: 13.7 sec |
Pablo: thanks for investigating and fixing this, I will look for examples of changing or patching sys.modules in the testsuite to see how to avoid global effects. I think we can keep this issue open for the follow-up discussion / fix? |
I've been looking into avoiding global modification of modules['__main__'], the options are:
I'm not sure if #3 is too heavy/complex for this test. The advantage of #1 and #2 is that it's easy to do and ensures that there won't be strange random test failures that are hard to track down and debug (which is something that I'm afraid can happen right now, caused by this test). #4 I've added to get comments / thought. |
Please disregard my last comment, I think I found a good way to fix it, the PR is up here: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: