This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_pdb fails
Type: Stage: resolved
Components: Tests Versions: Python 3.11
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, oliphaunt, sumagnadas, terry.reedy, trrhodes
Priority: normal Keywords:

Created on 2020-10-02 20:39 by sumagnadas, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28564 open oliphaunt, 2021-09-25 20:47
Messages (7)
msg377835 - (view) Author: Sumagna Das (sumagnadas) Date: 2020-10-02 20:39
I was thinking about contributing to cpython so i cloned it and followed the tests mentioned on devguide.python.org. When i ran my tests, it failed on two of them: test_pdb and test_ssl. test_ssl had an issue already as i found here. test_pdb failure was the one which i didn't find here. It failed with the following message:

== CPython 3.10.0a0 (heads/master:a937ab45d6, Oct 3 2020, 00:16:29) [GCC 9.3.0]
== Linux-5.4.0-48-generic-x86_64-with-glibc2.31 little-endian
== cwd: /mnt/sda2/github/cpython/build/test_python_21809æ
== CPU count: 4
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 1.52 Run tests in parallel using 2 child processes
0:00:06 load avg: 1.48 [1/1/1] test_pdb failed
test_blocks_at_first_code_line (test.test_pdb.PdbTestCase) ... ok
test_breakpoint (test.test_pdb.PdbTestCase) ... ok
test_errors_in_command (test.test_pdb.PdbTestCase) ... FAIL
test_find_function_empty_file (test.test_pdb.PdbTestCase) ... ok
test_find_function_found (test.test_pdb.PdbTestCase) ... ok
test_find_function_found_with_bom (test.test_pdb.PdbTestCase) ... ok
test_find_function_found_with_encoding_cookie (test.test_pdb.PdbTestCase) ... ok
test_header (test.test_pdb.PdbTestCase) ... ok
test_issue13120 (test.test_pdb.PdbTestCase) ... ok
test_issue13183 (test.test_pdb.PdbTestCase) ... ok
test_issue16180 (test.test_pdb.PdbTestCase) ... ok
test_issue36250 (test.test_pdb.PdbTestCase) ... ok
test_issue7964 (test.test_pdb.PdbTestCase) ... ok
test_module_is_run_as_main (test.test_pdb.PdbTestCase) ... ok
test_module_without_a_main (test.test_pdb.PdbTestCase) ... ok
test_readrc_homedir (test.test_pdb.PdbTestCase) ... ok
test_readrc_kwarg (test.test_pdb.PdbTestCase) ... ok
test_relative_imports (test.test_pdb.PdbTestCase) ... ok
test_relative_imports_on_plain_module (test.test_pdb.PdbTestCase) ... ok
test_run_module (test.test_pdb.PdbTestCase) ... ok
test_run_pdb_with_pdb (test.test_pdb.PdbTestCase) ... ok
test_list_commands (test.test_pdb)
Doctest: test.test_pdb.test_list_commands ... ok
test_next_until_return_at_return_event (test.test_pdb)
Doctest: test.test_pdb.test_next_until_return_at_return_event ... ok
test_pdb_basic_commands (test.test_pdb)
Doctest: test.test_pdb.test_pdb_basic_commands ... ok
test_pdb_breakpoint_commands (test.test_pdb)
Doctest: test.test_pdb.test_pdb_breakpoint_commands ... ok
test_pdb_continue_in_bottomframe (test.test_pdb)
Doctest: test.test_pdb.test_pdb_continue_in_bottomframe ... ok
test_pdb_displayhook (test.test_pdb)
Doctest: test.test_pdb.test_pdb_displayhook ... ok
test_pdb_issue_20766 (test.test_pdb)
Doctest: test.test_pdb.test_pdb_issue_20766 ... ok
test_pdb_next_command_for_asyncgen (test.test_pdb)
Doctest: test.test_pdb.test_pdb_next_command_for_asyncgen ... ok
test_pdb_next_command_for_coroutine (test.test_pdb)
Doctest: test.test_pdb.test_pdb_next_command_for_coroutine ... ok
test_pdb_next_command_for_generator (test.test_pdb)
Doctest: test.test_pdb.test_pdb_next_command_for_generator ... ok
test_pdb_next_command_in_generator_for_loop (test.test_pdb)
Doctest: test.test_pdb.test_pdb_next_command_in_generator_for_loop ... ok
test_pdb_next_command_subiterator (test.test_pdb)
Doctest: test.test_pdb.test_pdb_next_command_subiterator ... ok
test_pdb_return_command_for_coroutine (test.test_pdb)
Doctest: test.test_pdb.test_pdb_return_command_for_coroutine ... ok
test_pdb_return_command_for_generator (test.test_pdb)
Doctest: test.test_pdb.test_pdb_return_command_for_generator ... ok
test_pdb_run_with_code_object (test.test_pdb)
Doctest: test.test_pdb.test_pdb_run_with_code_object ... ok
test_pdb_run_with_incorrect_argument (test.test_pdb)
Doctest: test.test_pdb.test_pdb_run_with_incorrect_argument ... ok
test_pdb_skip_modules (test.test_pdb)
Doctest: test.test_pdb.test_pdb_skip_modules ... ok
test_pdb_skip_modules_with_callback (test.test_pdb)
Doctest: test.test_pdb.test_pdb_skip_modules_with_callback ... ok
test_pdb_until_command_for_coroutine (test.test_pdb)
Doctest: test.test_pdb.test_pdb_until_command_for_coroutine ... ok
test_pdb_until_command_for_generator (test.test_pdb)
Doctest: test.test_pdb.test_pdb_until_command_for_generator ... ok
test_pdb_whatis_command (test.test_pdb)
Doctest: test.test_pdb.test_pdb_whatis_command ... ok
test_post_mortem (test.test_pdb)
Doctest: test.test_pdb.test_post_mortem ... ok

======================================================================
FAIL: test_errors_in_command (test.test_pdb.PdbTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/sda2/github/cpython/Lib/test/test_pdb.py", line 1650, in test_errors_in_command
    self.assertEqual(stdout.splitlines()[1:], [
AssertionError: Lists differ: ['(Pd[283 chars]efined", 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ', '\x1b[?1034h'] != ['(Pd[283 chars]efined", 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ']

First list contains 1 additional elements.
First extra element 9:
'\x1b[?1034h'

  ['(Pdb) *** SyntaxError: unexpected EOF while parsing',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '*** SyntaxError: unexpected EOF while parsing',
   'LEAVING RECURSIVE DEBUGGER',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '> <string>(1)<module>()',
   "((Pdb)) *** NameError: name 'doesnotexist' is not defined",
   'LEAVING RECURSIVE DEBUGGER',
-  '(Pdb) ',
?          ^

+  '(Pdb) ']
?          ^

-  '\x1b[?1034h']

----------------------------------------------------------------------

Ran 43 tests in 5.143s

FAILED (failures=1)
test test_pdb failed

== Tests result: FAILURE ==

1 test failed:
    test_pdb

Total duration: 6.8 sec
Tests result: FAILURE

Is this happening only with me?
msg384072 - (view) Author: Ross Rhodes (trrhodes) * Date: 2020-12-30 17:15
Hi Sumagna,

test_pdb appears to be working as expected on my machine. I realise this was posted a few months ago so would you mind trying again and seeing if the issue persists? If so, which OS are you running your tests on?
msg398662 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-07-31 20:23
Sumagna,

Thanks for the report. The test is passing on our buildbots, so this is not a general problem with it.

It is hard to do anything about this without information about the platform and environment on which you saw the failure. If you are still seeing it, please create a new issue and include these details.
msg402166 - (view) Author: Léon Planken (oliphaunt) * Date: 2021-09-19 19:27
Re-opened as issue 45242 (also identified the culprit)
msg402584 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-24 20:14
Léon's message from #45242, which I closed as a duplicate of this.

Leon: please try with 3.11 (best, repository main), 3.10, or at least 3.9.  3.8 and before only get security fixes.
---

Building Python 3.7, I ran into the same issue reported [here] (only line numbers differ):

======================================================================
FAIL: test_errors_in_command (__main__.PdbTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_pdb.py", line 1535, in test_errors_in_command
    '(Pdb) ',
AssertionError: Lists differ: ['(Pd[283 chars]efined", 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ', '\x1b[?1034h'] != ['(Pd[283 chars]efined", 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ']

First list contains 1 additional elements.
First extra element 9:
'\x1b[?1034h'

  ['(Pdb) *** SyntaxError: unexpected EOF while parsing',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '*** SyntaxError: unexpected EOF while parsing',
   'LEAVING RECURSIVE DEBUGGER',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '> <string>(1)<module>()',
   "((Pdb)) *** NameError: name 'doesnotexist' is not defined",
   'LEAVING RECURSIVE DEBUGGER',
-  '(Pdb) ',
?          ^

+  '(Pdb) ']
?          ^

-  '\x1b[?1034h']

----------------------------------------------------------------------
Ran 39 tests in 1.024s

FAILED (failures=1)


I have also managed to determine the cause.  As can be seen, the output from this pdb invocation contains an extraneous ANSI control sequence ("interpret "meta" key, set eighth bit"). This happens when running the test inside the GNU `screen` environment.  Run the test outside `screen`, and the problem goes away.

(By the way, this was the only test that failed when running `make test` inside the `screen` environment.)
msg402622 - (view) Author: Léon Planken (oliphaunt) * Date: 2021-09-25 13:44
Here's the issue again when running test_pdb.py for 3.11 (repository main). The same problem now occurs twice, and only inside the `screen` environment.

----- 8< -----

~/Temp/cpython> ./python Lib/test/test_pdb.py
.....F.........F........................................
======================================================================
FAIL: test_errors_in_command (__main__.PdbTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/leon/Temp/cpython/Lib/test/test_pdb.py", line 1847, in test_errors_in_command
    self.assertEqual(stdout.splitlines()[1:], [
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Lists differ: ['-> [278 chars]efined", 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ', '\x1b[?1034h'] != ['-> [278 chars]efined", 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ']

First list contains 1 additional elements.
First extra element 10:
'\x1b[?1034h'

  ['-> pass',
   "(Pdb) *** SyntaxError: '(' was never closed",
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   "*** SyntaxError: '(' was never closed",
   'LEAVING RECURSIVE DEBUGGER',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '> <string>(1)<module>()',
   "((Pdb)) *** NameError: name 'doesnotexist' is not defined",
   'LEAVING RECURSIVE DEBUGGER',
-  '(Pdb) ',
?          ^

+  '(Pdb) ']
?          ^

-  '\x1b[?1034h']

======================================================================
FAIL: test_issue34266 (__main__.PdbTestCase)
do_run handles exceptions from parsing its arg
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/leon/Temp/cpython/Lib/test/test_pdb.py", line 1875, in test_issue34266
    check('\\', 'No escaped character')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/leon/Temp/cpython/Lib/test/test_pdb.py", line 1870, in check
    self.assertEqual(stdout.splitlines()[1:], [
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Lists differ: ['-> [13 chars] *** Cannot run \\: No escaped character', '(Pdb) \x1b[?1034h'] != ['-> [13 chars] *** Cannot run \\: No escaped character', '(Pdb) ']

First differing element 2:
'(Pdb) \x1b[?1034h'
'(Pdb) '

- ['-> pass',
-  '(Pdb) *** Cannot run \\: No escaped character',
+ ['-> pass', '(Pdb) *** Cannot run \\: No escaped character', '(Pdb) ']
? +++++++++++                                                 ++++++++++

-  '(Pdb) \x1b[?1034h']

----------------------------------------------------------------------
Ran 56 tests in 2.850s

FAILED (failures=2)
msg402647 - (view) Author: Léon Planken (oliphaunt) * Date: 2021-09-25 21:01
So I went ahead to fix the issue and created a PR. I also signed the CLA, but I understand that needs a little time to process.
I was bold/forward enough to add myself to the ACKS. Please feel remove me if this contribution is too trivial.
History
Date User Action Args
2022-04-11 14:59:36adminsetgithub: 86080
2021-09-25 21:01:07oliphauntsetmessages: + msg402647
2021-09-25 20:47:08oliphauntsetpull_requests: + pull_request26948
2021-09-25 13:44:13oliphauntsetmessages: + msg402622
versions: + Python 3.11, - Python 3.10
2021-09-24 20:14:41terry.reedysetresolution: works for me ->

messages: + msg402584
nosy: + terry.reedy
2021-09-24 20:09:24terry.reedylinkissue45242 superseder
2021-09-19 19:27:47oliphauntsetnosy: + oliphaunt
messages: + msg402166
2021-07-31 20:23:53iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg398662

resolution: works for me
stage: resolved
2020-12-30 17:15:52trrhodessetnosy: + trrhodes
messages: + msg384072
2020-10-02 20:43:28sumagnadassettitle: test_pdb fails wit -> test_pdb fails
2020-10-02 20:39:35sumagnadascreate