-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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_pdb fails in refleak mode #64945
Comments
$ ./python -m test -W -R3:3 test_pdb
[1/1] test_pdb
[...] ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_list_commands
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 288, in test_list_commands
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 311, in test.test_pdb.test_list_commands
Failed example:
with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
'list', # list first function
'step', # step into second function
'list', # list second function
'list', # continue listing to EOF
'list 1,3', # list specific lines
'list x', # invalid argument
'next', # step to import
'next', # step over import
'step', # step into do_nothing
'longlist', # list all lines
'source do_something', # list all lines of function
'source fooxxx', # something that doesn't exit
'continue',
]):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_list_commands[2]>", line 1, in <module>
with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_next_until_return_at_return_event
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 603, in test_next_until_return_at_return_event
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 617, in test.test_pdb.test_next_until_return_at_return_event
Failed example:
with PdbTestInput(['break test_function_2',
'continue',
'return',
'next',
'continue',
'return',
'until',
'continue',
'return',
'return',
'continue']):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_next_until_return_at_return_event[2]>", line 1, in <module>
with PdbTestInput(['break test_function_2',
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_basic_commands
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 62, in test_pdb_basic_commands
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 81, in test.test_pdb.test_pdb_basic_commands
Failed example:
with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
'step', # entering the function call
'args', # display function args
'list', # list function source
'bt', # display backtrace
'up', # step up to test_function()
'down', # step down to test_function_2() again
'next', # stepping to print(foo)
'next', # stepping to the for loop
'step', # stepping into the for loop
'until', # continuing until out of the for loop
'next', # executing the print(bar)
'jump 8', # jump over second for loop
'return', # return out of function
'retval', # display return value
'continue',
]):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_basic_commands[2]>", line 1, in <module>
with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_breakpoint_commands
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 172, in test_pdb_breakpoint_commands
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 194, in test.test_pdb.test_pdb_breakpoint_commands
Failed example:
with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
'break 3',
'disable 1',
'ignore 1 10',
'condition 1 1 < 2',
'break 4',
'break 4',
'break',
'clear 3',
'break',
'condition 1',
'enable 1',
'clear 1',
'commands 2',
'p "42"',
'print("42", 7*6)', # Issue 18764 (not about breakpoints)
'end',
'continue', # will stop at breakpoint 2 (line 4)
'clear', # clear all!
'y',
'tbreak 5',
'continue', # will stop at temporary breakpoint
'break', # make sure breakpoint is gone
'continue',
]):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_breakpoint_commands[5]>", line 1, in <module>
with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_continue_in_bottomframe
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 517, in test_pdb_continue_in_bottomframe
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 529, in test.test_pdb.test_pdb_continue_in_bottomframe
Failed example:
with PdbTestInput([ # doctest: +ELLIPSIS
'next',
'break 7',
'continue',
'next',
'continue',
'continue',
]):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_continue_in_bottomframe[1]>", line 1, in <module>
with PdbTestInput([ # doctest: +ELLIPSIS
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_displayhook
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 33, in test_pdb_displayhook
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 40, in test.test_pdb.test_pdb_displayhook
Failed example:
with PdbTestInput([
'foo',
'bar',
'for i in range(5): print(i)',
'continue',
]):
test_function(1, None)
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_displayhook[1]>", line 1, in <module>
with PdbTestInput([
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_next_command_for_generator
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 666, in test_pdb_next_command_for_generator
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 684, in test.test_pdb.test_pdb_next_command_for_generator
Failed example:
with PdbTestInput(['step',
'step',
'step',
'next',
'next',
'step',
'step',
'continue']):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_next_command_for_generator[2]>", line 1, in <module>
with PdbTestInput(['step',
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_next_command_in_generator_for_loop
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 820, in test_pdb_next_command_in_generator_for_loop
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 833, in test.test_pdb.test_pdb_next_command_in_generator_for_loop
Failed example:
with PdbTestInput(['break test_gen',
'continue',
'next',
'next',
'next',
'continue']):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[2]>", line 1, in <module>
with PdbTestInput(['break test_gen',
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_next_command_subiterator
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 861, in test_pdb_next_command_subiterator
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 878, in test.test_pdb.test_pdb_next_command_subiterator
Failed example:
with PdbTestInput(['step',
'step',
'next',
'next',
'next',
'continue']):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_next_command_subiterator[3]>", line 1, in <module>
with PdbTestInput(['step',
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_return_command_for_generator
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 723, in test_pdb_return_command_for_generator
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 742, in test.test_pdb.test_pdb_return_command_for_generator
Failed example:
with PdbTestInput(['step',
'step',
'step',
'return',
'step',
'step',
'continue']):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_return_command_for_generator[2]>", line 1, in <module>
with PdbTestInput(['step',
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_run_with_code_object
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 581, in test_pdb_run_with_code_object
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 584, in test.test_pdb.test_pdb_run_with_code_object
Failed example:
with PdbTestInput(['step','x', 'continue']): # doctest: +ELLIPSIS
pdb_invoke('run', compile('x=1', '<string>', 'exec'))
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_run_with_code_object[0]>", line 1, in <module>
with PdbTestInput(['step','x', 'continue']): # doctest: +ELLIPSIS
NameError: name 'PdbTestInput' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 594, in test.test_pdb.test_pdb_run_with_code_object
Failed example:
with PdbTestInput(['x', 'continue']):
x=0
pdb_invoke('runeval', compile('x+1', '<string>', 'eval'))
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_run_with_code_object[1]>", line 1, in <module>
with PdbTestInput(['x', 'continue']):
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_run_with_incorrect_argument
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 565, in test_pdb_run_with_incorrect_argument
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 568, in test.test_pdb.test_pdb_run_with_incorrect_argument
Failed example:
pti = PdbTestInput(['continue',])
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_run_with_incorrect_argument[0]>", line 1, in <module>
pti = PdbTestInput(['continue',])
NameError: name 'PdbTestInput' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 569, in test.test_pdb.test_pdb_run_with_incorrect_argument
Failed example:
with pti:
pdb_invoke('run', lambda x: x)
Expected:
Traceback (most recent call last):
TypeError: exec() arg 1 must be a string, bytes or code object
Got:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_run_with_incorrect_argument[1]>", line 1, in <module>
with pti:
NameError: name 'pti' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 574, in test.test_pdb.test_pdb_run_with_incorrect_argument
Failed example:
with pti:
pdb_invoke('runeval', lambda x: x)
Expected:
Traceback (most recent call last):
TypeError: eval() arg 1 must be a string, bytes or code object
Got:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_run_with_incorrect_argument[2]>", line 1, in <module>
with pti:
NameError: name 'pti' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_skip_modules
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 446, in test_pdb_skip_modules
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 454, in test.test_pdb.test_pdb_skip_modules
Failed example:
with PdbTestInput([
'step',
'continue',
]):
skip_module()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_skip_modules[1]>", line 1, in <module>
with PdbTestInput([
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_skip_modules_with_callback
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 474, in test_pdb_skip_modules_with_callback
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 483, in test.test_pdb.test_pdb_skip_modules_with_callback
Failed example:
with PdbTestInput([
'step',
'step',
'step',
'step',
'step',
'continue',
]):
skip_module()
pass # provides something to "step" to
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_skip_modules_with_callback[1]>", line 1, in <module>
with PdbTestInput([
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_pdb_until_command_for_generator
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 776, in test_pdb_until_command_for_generator
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 791, in test.test_pdb.test_pdb_until_command_for_generator
Failed example:
with PdbTestInput(['step',
'until 4',
'step',
'step',
'continue']):
test_function()
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_pdb_until_command_for_generator[2]>", line 1, in <module>
with PdbTestInput(['step',
NameError: name 'PdbTestInput' is not defined ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_pdb.test_post_mortem
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 384, in test_post_mortem
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_pdb.py", line 398, in test.test_pdb.test_post_mortem
Failed example:
with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
'next', # step over exception-raising call
'bt', # get a backtrace
'list', # list code of test_function()
'down', # step into test_function_2()
'list', # list code of test_function_2()
'continue',
]):
try:
test_function()
except ZeroDivisionError:
print('Correctly reraised.')
Exception raised:
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest test.test_pdb.test_post_mortem[2]>", line 1, in <module>
with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
NameError: name 'PdbTestInput' is not defined |
The doctests are executed with 'test.globs' as globals which is set in the 'find' method of doctest.DocTestFinder, and cleared after each run (unless 'clear_globs' is false). One possible fix is to have test.regrtest 'find' a new test_runner before each run instead of always using the same one. This is what does the attached patch. |
See also bpo-20766. |
test_statistics also defines a load_tests() function that builds unittest tests from doctests with doctest.DocTestSuite() and also fails in refleak mode. The above regrtest.diff patch also fixes the test_statistics in refleak mode. |
This is because breakpoints number are class attributes. With the following change, the "./python -m test test_pdb test_pdb" is ok: $ hg diff
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -614,6 +614,8 @@
... test_function_2()
... end = 1
+ >>> from bdb import Breakpoint; Breakpoint.next = 1
+
>>> with PdbTestInput(['break test_function_2',
... 'continue',
... 'return', Attached refleak_3.patch fixes this problem for test_next_until_return_at_return_event(). |
Sorry, I posted to the wrong issue, please ignore my previous message. |
New changeset df832e0c6d7d by Antoine Pitrou in branch '3.4': New changeset d2041159e8ed by Antoine Pitrou in branch 'default': |
The regrtest.py part has been fixed independently in bpo-22104 (thank you Zachary). I've now pushed the rest of the patch for test_pdb. Thank you Xavier! |
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: