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
tests mutating sys.gettrace() w/o re-instating previous state #55199
Comments
The attached patch adds resource monitoring to test.regrtest to detect which tests are changing the trace function w/o putting back to what it was previously. The tests listed below are thus all being naughty. This is a meta-issue to help track which tests need to be changed to stop this behavior. test_doctest |
Cinder on IRC found that test_exception's RuntimeError test triggers a trace_trampoline() line of code which resets the trace function as an exception gets triggered in the trace function itself. test_doctest is being messy and setting pdb's trace function w/o putting back what it wrote over. |
test_pickle and test_pickletools both call test_bad_getattr in pickletester.py:1005 This results in a RuntimeError which leads to the same result as test_exceptions |
test_pdb uses pdb.set_trace() w/o putting the original trace function back. |
test_scope blindly resets the trace function to None. |
And here is a revelation: test_sys_settrace clobbers the trace function blindly. |
test_zipimport_support fails because test_doctest fails; it re-runs the tests from a zipfile. |
test_io is causing coverage.py to complain thanks to the TextIOWrapperTests, and the regrtest check is complaining about SignalsTests. Don't know why specifically for either. |
test_runpy fails because of a recursion depth test (test_main_recursion_error). |
test_richcmp is failing because of a recursion test (test_recursion) |
For test_io.*SignalsTests, its all the tests calling check_interrupted_write(). For TestIOWrapperTests its test_threads_write() (although only coverage.py is complaining, not regrtest). |
OK, now that all the modules have been analyzed, let's see what is what. The modules not playing nicely with others by blindly reseting the trace module: test_doctest And the tests failing because of recursion depth: And test_io is just special thanks to signals and threading. Here is my thinking on how to solve this. The tests that are not playing nicely with sys.settrace() should (a) be decorated with test.support.cpython_only, and (b) use addCleanup() to properly put the trace function back. For the recursion depth tests, either the cause (which is probably trace_trampoline()) needs to be analyzed to decide if some other semantics are needed or need something to unset the trace function and then put it back, but only if sys.gettrace() exists (e.g., don't block on non-CPython VMs). |
Here is a patch that fixes test_scope. |
Here is a partial patch for test_sys_settrace. It fails on test_19_no_jump_without_trace_function for some reason I don't understand. It also doesn't protect against it being CPython-only as that is a function decorator and basically the whole module needs to be skipped. |
test_trace can be added to this list, each call to runfunc does a sys.settrace() 121: self.tracer.runfunc(traced_func_loop, 2, 3) |
Thanks for the diagnosis, Kristian. Attached is a patch for test_trace which fixes its over-zealous setting of the trace function (doesn't address the failures, though). |
Here is a patch for test_pdb; the context manager made this dirt-simple to fix. |
Patch for doctest/test_doctest (yes, both files were wiping out the trace function. |
And with this patch for test_zipimport_support to work thanks to the test_doctest changes, all of the test suites blasting the trace function *should* be fixed. |
I have a patch that I am testing right now which deals which fixes all the test suites. |
OK, here is a single patch (from |
OK, here is an updated patch that fixes the introduced failure in test_sys_settrace. This should be ready to go for Python 3.3 once the tree opens up (unless someone reviews it and finds a problem). |
Cleaned up patch file. Removed non-related diffs and redundant updates. refcount_test decorator is still in there. |
Attached is a fixed copy of Kristian's patch; error in test_trace where self.settrace was being called. |
Sorry about that. New patch attached. |
Updated patch that applies cleanly. |
r88467 has it for 3.3. |
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: