Skip to content
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 suite interrupted by xml.etree.ElementTree.ParseError: not well-formed (invalid token) #121188

Closed
vstinner opened this issue Jun 30, 2024 · 8 comments
Assignees
Labels
tests Tests in the Lib/test dir topic-XML

Comments

@vstinner
Copy link
Member

vstinner commented Jun 30, 2024

It seems like the problem comes from 0x1b bytes (eg: displayed as ^[ in vim editor), ANSI escape sequence, which is not properly escaped.

Example: https://buildbot.python.org/all/#/builders/332/builds/1457

0:04:35 load avg: 8.27 [350/478] test_sys_setprofile passed -- running (1): test.test_multiprocessing_spawn.test_processes (30.2 sec)
0:04:36 load avg: 8.27 [351/478] test_named_expressions passed -- running (1): test.test_multiprocessing_spawn.test_processes (30.4 sec)
['<testsuite start="2024-06-30 10:05:12.412148" tests="117" errors="0" failures="1"><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_empty" status="run" result="completed" time="0.000074" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_character_key" status="run" result="completed" time="0.000064" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_character_key_with_stack" status="run" result="completed" time="0.000071" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_invalid_key" status="run" result="completed" time="0.000046" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_invalid_key_with_stack" status="run" result="completed" time="0.000051" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_invalid_key_with_unicode_category" status="run" result="completed" time="0.000045" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_multiple_keys" status="run" result="completed" time="0.000048" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_single_key" status="run" result="completed" time="0.000043" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_transition_key" status="run" result="completed" time="0.000065" /><testcase name="test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_transition_key_interrupted" status="run" result="completed" time="0.000060" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_empty" status="run" result="completed" time="0.000075" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_multiple_statements" status="run" result="completed" time="0.000976" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_multiple_statements_output" status="run" result="completed" time="0.000235" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_no_active_future" status="run" result="completed" time="0.000209" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_runsource_compiles_and_runs_code" status="run" result="completed" time="0.000468" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_runsource_returns_false_for_failed_compilation" status="run" result="completed" time="0.000162" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_runsource_returns_false_for_successful_compilation" status="run" result="completed" time="0.000115" /><testcase name="test.test_pyrepl.test_interact.TestSimpleInteract.test_runsource_shows_syntax_error_for_failed_compilation" status="run" result="completed" time="0.000879" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_clashing_definitions" status="run" result="completed" time="0.000062" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_empty_keymap" status="run" result="completed" time="0.000033" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_empty_value" status="run" result="completed" time="0.000036" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_multiple_empty_values" status="run" result="completed" time="0.000035" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_multiple_keymaps" status="run" result="completed" time="0.000034" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_nested_keymap" status="run" result="completed" time="0.000034" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_nested_multiple_keymaps" status="run" result="completed" time="0.000034" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_non_bytes_key" status="run" result="completed" time="0.000045" /><testcase name="test.test_pyrepl.test_keymap.TestCompileKeymap.test_single_keymap" status="run" result="completed" time="0.000034" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_combinations" status="run" result="completed" time="0.000063" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_control_sequences" status="run" result="completed" time="0.000030" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_escape_sequences" status="run" result="completed" time="0.000296" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_index_errors" status="run" result="completed" time="0.000069" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_keynames" status="run" result="completed" time="0.000864" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_keyspec_errors" status="run" result="completed" time="0.000334" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_meta_sequences" status="run" result="completed" time="0.000044" /><testcase name="test.test_pyrepl.test_keymap.TestParseKeys.test_single_character" status="run" result="completed" time="0.001213" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_after_wrap_and_move_up" status="run" result="completed" time="0.009281" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_double_width_character" status="run" result="completed" time="0.004559" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_double_width_character_move_left" status="run" result="completed" time="0.004815" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_double_width_character_move_left_right" status="run" result="completed" time="0.005351" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_double_width_characters_move_up" status="run" result="completed" time="0.012739" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_double_width_characters_move_up_down" status="run" result="completed" time="0.011296" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_move_down_to_eol" status="run" result="completed" time="0.010642" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_move_up_to_eol" status="run" result="completed" time="0.010715" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_multiple_double_width_characters_move_left" status="run" result="completed" time="0.007659" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_multiple_mixed_lines_move_up" status="run" result="completed" time="0.018315" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_cursor_position_simple_character" status="run" result="completed" time="0.003981" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_down_arrow_end_of_input" status="run" result="completed" time="0.007747" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_left_arrow_simple" status="run" result="completed" time="0.006869" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_right_arrow_end_of_line" status="run" result="completed" time="0.005664" /><testcase name="test.test_pyrepl.test_pyrepl.TestCursorPosition.test_up_arrow_simple" status="run" result="completed" time="0.007966" /><testcase name="test.test_pyrepl.test_pyrepl.TestMain.test_dumb_terminal_exits_cleanly" status="run" result="completed" time="0.604765" /><testcase name="test.test_pyrepl.test_pyrepl.TestMain.test_exposed_globals_in_repl" status="run" result="completed" time="0.587335"><system-out /><system-err /><failure type="AssertionError" message="AssertionError: False is not true : sorted(dir())&#13;&#10;exit&#13;&#10;&#10;Python 3.14.0a0 (heads/refs/pull/120894/merge:3ea9e550eef, Jun 30 2024, 06:00:16) [GCC 7.5.0] on linux&#13;&#10;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&#13;&#10;&#10;\x1b[?2004h&#10;\x1b[?1h\x1b=\x1b[?25l\x1b[1A&#10;\x1b[1;35m&gt;&gt;&gt; \x1b[0m\x1b[4D&#10;\x1b[?12l\x1b[?25h\x1b[4C&#10;\x1b[?25l\x1b[4D\x1b[1;35m&gt;&gt;&gt; \x1b[0ms\x1b[5D\x1b[?12l\x1b[?25h\x1b[5C&#10;\x1b[?25l\x1b[5D\x1b[1;35m&gt;&gt;&gt; \x1b[0mso\x1b[6D\x1b[?12l\x1b[?25h\x1b[6C&#10;\x1b[?25l\x1b[6D\x1b[1;35m&gt;&gt;&gt; \x1b[0msor\x1b[7D&#10;\x1b[?12l\x1b[?25h\x1b[7C&#10;\x1b[?25l\x1b[7D\x1b[1;35m&gt;&gt;&gt; \x1b[0msort\x1b[8D&#10;\x1b[?12l\x1b[?25h\x1b[8C&#10;\x1b[?25l\x1b[8D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorte\x1b[9D&#10;\x1b[?12l\x1b[?25h\x1b[9C&#10;\x1b[?25l\x1b[9D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted&#10;\x1b[10D&#10;\x1b[?12l\x1b[?25h\x1b[10C&#10;\x1b[?25l\x1b[10D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(&#10;\x1b[11D&#10;\x1b[?12l\x1b[?25h\x1b[11C&#10;\x1b[?25l\x1b[11D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(d\x1b[12D\x1b[?12l\x1b[?25h\x1b[12C&#10;\x1b[?25l\x1b[12D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(di\x1b[13D&#10;\x1b[?12l\x1b[?25h\x1b[13C&#10;\x1b[?25l\x1b[13D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir&#10;\x1b[14D&#10;\x1b[?12l\x1b[?25h\x1b[14C&#10;\x1b[?25l\x1b[14D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir(\x1b[15D\x1b[?12l\x1b[?25h\x1b[15C&#10;\x1b[?25l\x1b[15D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir()&#10;\x1b[16D&#10;\x1b[?12l\x1b[?25h\x1b[16C&#10;\x1b[?25l\x1b[16D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir())\x1b[17D&#10;\x1b[?12l\x1b[?25h\x1b[17C&#10;\x1b[17D&#10;&#13;&#10;\x1b[?2004l&#10;\x1b[?1l\x1b&gt;&#10;[\'__annotations__\', \'__builtins__\', \'__cached__\', \'__doc__\', \'__file__\', \'__loader__\', \'__name__\', \'__package__\', \'__spec__\', \'sys\', \'ver\']&#13;&#10;&#10;\x1b[?2004h&#10;\x1b[?1h\x1b=\x1b[?25l\x1b[1A&#10;&#10;\x1b[1;35m&gt;&gt;&gt; \x1b[0m&#10;\x1b[4D&#10;\x1b[?12l\x1b[?25h\x1b[4C&#10;\x1b[?25l\x1b[4D\x1b[1;35m&gt;&gt;&gt; \x1b[0me\x1b[5D\x1b[?12l\x1b[?25h\x1b[5C&#10;\x1b[?25l\x1b[5D\x1b[1;35m&gt;&gt;&gt; \x1b[0mex\x1b[6D&#10;\x1b[?12l\x1b[?25h\x1b[6C&#10;\x1b[?25l\x1b[6D\x1b[1;35m&gt;&gt;&gt; \x1b[0mexi&#10;\x1b[7D&#10;\x1b[?12l\x1b[?25h\x1b[7C&#10;\x1b[?25l\x1b[7D\x1b[1;35m&gt;&gt;&gt; \x1b[0mexit\x1b[8D\x1b[?12l\x1b[?25h\x1b[8C\x1b[8D&#10;&#13;\x1b[?2004l\x1b[?1l\x1b&gt;&#10;">Traceback (most recent call last):\n  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/unittest/case.py", line 58, in testPartExecutor\n    yield\n  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/unittest/case.py", line 660, in run\n    self._callTestMethod(testMethod)\n    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^\n  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/unittest/case.py", line 606, in _callTestMethod\n    result = method()\n  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/support/__init__.py", line 2622, in wrapper\n    return func(*args, **kwargs)\n  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/test_pyrepl/test_pyrepl.py", line 865, in test_exposed_globals_in_repl\n    self.assertTrue(case1 or case2 or case3 or case4, output)\n    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/unittest/case.py", line 753, in assertTrue\n    raise self.failureException(msg)\nAssertionError: False is not true : sorted(dir())\r\nexit\r\n\nPython 3.14.0a0 (heads/refs/pull/120894/merge:3ea9e550eef, Jun 30 2024, 06:00:16) [GCC 7.5.0] on linux\r\nType "help", "copyright", "credits" or "license" for more information.\r\n\n\x1b[?2004h\n\x1b[?1h\x1b=\x1b[?25l\x1b[1A\n\x1b[1;35m&gt;&gt;&gt; \x1b[0m\x1b[4D\n\x1b[?12l\x1b[?25h\x1b[4C\n\x1b[?25l\x1b[4D\x1b[1;35m&gt;&gt;&gt; \x1b[0ms\x1b[5D\x1b[?12l\x1b[?25h\x1b[5C\n\x1b[?25l\x1b[5D\x1b[1;35m&gt;&gt;&gt; \x1b[0mso\x1b[6D\x1b[?12l\x1b[?25h\x1b[6C\n\x1b[?25l\x1b[6D\x1b[1;35m&gt;&gt;&gt; \x1b[0msor\x1b[7D\n\x1b[?12l\x1b[?25h\x1b[7C\n\x1b[?25l\x1b[7D\x1b[1;35m&gt;&gt;&gt; \x1b[0msort\x1b[8D\n\x1b[?12l\x1b[?25h\x1b[8C\n\x1b[?25l\x1b[8D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorte\x1b[9D\n\x1b[?12l\x1b[?25h\x1b[9C\n\x1b[?25l\x1b[9D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted\n\x1b[10D\n\x1b[?12l\x1b[?25h\x1b[10C\n\x1b[?25l\x1b[10D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(\n\x1b[11D\n\x1b[?12l\x1b[?25h\x1b[11C\n\x1b[?25l\x1b[11D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(d\x1b[12D\x1b[?12l\x1b[?25h\x1b[12C\n\x1b[?25l\x1b[12D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(di\x1b[13D\n\x1b[?12l\x1b[?25h\x1b[13C\n\x1b[?25l\x1b[13D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir\n\x1b[14D\n\x1b[?12l\x1b[?25h\x1b[14C\n\x1b[?25l\x1b[14D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir(\x1b[15D\x1b[?12l\x1b[?25h\x1b[15C\n\x1b[?25l\x1b[15D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir()\n\x1b[16D\n\x1b[?12l\x1b[?25h\x1b[16C\n\x1b[?25l\x1b[16D\x1b[1;35m&gt;&gt;&gt; \x1b[0msorted(dir())\x1b[17D\n\x1b[?12l\x1b[?25h\x1b[17C\n\x1b[17D\n\r\n\x1b[?2004l\n\x1b[?1l\x1b&gt;\n[\'__annotations__\', \'__builtins__\', \'__cached__\', \'__doc__\', \'__file__\', \'__loader__\', \'__name__\', \'__package__\', \'__spec__\', \'sys\', \'ver\']\r\n\n\x1b[?2004h\n\x1b[?1h\x1b=\x1b[?25l\x1b[1A\n\n\x1b[1;35m&gt;&gt;&gt; \x1b[0m\n\x1b[4D\n\x1b[?12l\x1b[?25h\x1b[4C\n\x1b[?25l\x1b[4D\x1b[1;35m&gt;&gt;&gt; \x1b[0me\x1b[5D\x1b[?12l\x1b[?25h\x1b[5C\n\x1b[?25l\x1b[5D\x1b[1;35m&gt;&gt;&gt; \x1b[0mex\x1b[6D\n\x1b[?12l\x1b[?25h\x1b[6C\n\x1b[?25l\x1b[6D\x1b[1;35m&gt;&gt;&gt; \x1b[0mexi\n\x1b[7D\n\x1b[?12l\x1b[?25h\x1b[7C\n\x1b[?25l\x1b[7D\x1b[1;35m&gt;&gt;&gt; \x1b[0mexit\x1b[8D\x1b[?12l\x1b[?25h\x1b[8C\x1b[8D\n\r\x1b[?2004l\x1b[?1l\x1b&gt;\n</failure></testcase><testcase name="test.test_pyrepl.test_pyrepl.TestMain.test_python_basic_repl" status="run" result="completed" time="1.247115" /><testcase name="test.test_pyrepl.test_pyrepl.TestPasteEvent.test_bracketed_paste" status="run" result="completed" time="0.004426" /><testcase name="test.test_pyrepl.test_pyrepl.TestPasteEvent.test_bracketed_paste_single_line" status="run" result="completed" time="0.002461" /><testcase name="test.test_pyrepl.test_pyrepl.TestPasteEvent.test_paste" status="run" result="completed" time="0.006187" /><testcase name="test.test_pyrepl.test_pyrepl.TestPasteEvent.test_paste_mid_newlines" status="run" result="completed" time="0.003866" /><testcase name="test.test_pyrepl.test_pyrepl.TestPasteEvent.test_paste_mid_newlines_not_in_paste_mode" status="run" result="completed" time="0.003064" /><testcase name="test.test_pyrepl.test_pyrepl.TestPasteEvent.test_paste_not_in_paste_mode" status="run" result="completed" time="0.005041" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplAutoindent.test_auto_indent_continuation" status="run" result="completed" time="0.003406" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplAutoindent.test_auto_indent_default" status="run" result="completed" time="0.000031" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplAutoindent.test_auto_indent_ignore_comments" status="run" result="completed" time="0.003174" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplAutoindent.test_auto_indent_multiline" status="run" result="completed" time="0.003716" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplAutoindent.test_auto_indent_prev_block" status="run" result="completed" time="0.004236" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplAutoindent.test_auto_indent_with_comment" status="run" result="completed" time="0.003255" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplCompleter.test_completion_with_many_options" status="run" result="completed" time="0.074031" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplCompleter.test_completion_with_warnings" status="run" result="completed" time="0.010621" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplCompleter.test_empty_namespace_completion" status="run" result="completed" time="0.002656" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplCompleter.test_global_namespace_completion" status="run" result="completed" time="0.002461" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplCompleter.test_simple_completion" status="run" result="completed" time="0.004463" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplCompleter.test_updown_arrow_with_completion_menu" status="run" result="completed" time="0.073284" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplOutput.test_basic" status="run" result="completed" time="0.002418" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplOutput.test_control_character" status="run" result="completed" time="0.002317" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplOutput.test_history_navigation_with_down_arrow" status="run" result="completed" time="0.002359" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplOutput.test_history_navigation_with_up_arrow" status="run" result="completed" time="0.004004" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplOutput.test_history_search" status="run" result="completed" time="0.003447" /><testcase name="test.test_pyrepl.test_pyrepl.TestPyReplOutput.test_multiline_edit" status="run" result="completed" time="0.003851" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_backspace" status="run" result="completed" time="0.008366" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_backspace_in_second_line_after_wrap" status="run" result="completed" time="0.007194" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_wrap_removes_after_backspace" status="run" result="completed" time="0.006498" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_wrap_simple" status="run" result="completed" time="0.012438" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_wrap_three_lines" status="run" result="completed" time="0.008426" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_wrap_three_lines_mixed_character" status="run" result="completed" time="0.009177" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_calc_screen_wrap_wide_characters" status="run" result="completed" time="0.005860" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_completions_updated_on_key_press" status="run" result="completed" time="0.012732" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_input_hook_is_called_if_set" status="run" result="completed" time="0.012378" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_key_press_on_tab_press_once" status="run" result="completed" time="0.009018" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_keyboard_interrupt_clears_screen" status="run" result="completed" time="0.025747" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_newline_within_block_trailing_whitespace" status="run" result="completed" time="0.012264" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_prompt_length" status="run" result="completed" time="0.000110" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_setpos_for_xy_simple" status="run" result="completed" time="0.004700" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_setpos_from_xy_after_wrap" status="run" result="completed" time="0.007858" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_setpos_from_xy_multiple_lines" status="run" result="completed" time="0.008174" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_setpos_fromxy_in_wrapped_line" status="run" result="completed" time="0.035877" /><testcase name="test.test_pyrepl.test_reader.TestReader.test_up_arrow_after_ctrl_r" status="run" result="completed" time="0.005097" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_cursor_back_write" status="run" result="completed" time="0.003763" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_cursor_left" status="run" result="completed" time="0.003459" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_cursor_left_right" status="run" result="completed" time="0.004322" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_cursor_up" status="run" result="completed" time="0.003993" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_cursor_up_down" status="run" result="completed" time="0.004148" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_multiline_function_move_up_down_short_terminal" status="run" result="completed" time="0.034868" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_multiline_function_move_up_short_terminal" status="run" result="completed" time="0.005552" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_resize_bigger_on_multiline_function" status="run" result="completed" time="0.006622" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_resize_smaller_on_multiline_function" status="run" result="completed" time="0.007210" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_simple_addition" status="run" result="completed" time="0.003960" /><testcase name="test.test_pyrepl.test_unix_console.TestConsole.test_wrap" status="run" result="completed" time="0.004245" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_empty" status="run" result="completed" time="0.000385" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_flush_buf" status="run" result="completed" time="0.000222" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_get" status="run" result="completed" time="0.000213" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_insert" status="run" result="completed" time="0.000205" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_push_special_key" status="run" result="completed" time="0.000232" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_push_unrecognized_escape_sequence" status="run" result="completed" time="0.000231" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_push_with_key_in_keymap" status="run" result="completed" time="0.000604" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_push_with_keymap_in_keymap" status="run" result="completed" time="0.000589" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_push_with_keymap_in_keymap_and_escape" status="run" result="completed" time="0.001690" /><testcase name="test.test_pyrepl.test_unix_eventqueue.TestUnixEventQueue.test_push_without_key_in_keymap" status="run" result="completed" time="0.000566" /><testcase name="unittest.loader.ModuleSkipped.test.test_pyrepl.test_windows_console" status="run" result="completed" time="0.000009"><skipped>test only relevant on win32</skipped></testcase></testsuite>']
Kill <WorkerThread #1 running test=test_fork1 pid=17421 time=4.6 sec> process group
Kill <WorkerThread #2 running test=test_tools pid=13493 time=15.5 sec> process group
Kill <WorkerThread #3 running test=test.test_multiprocessing_spawn.test_misc pid=13075 time=23.5 sec> process group
Kill <WorkerThread #5 running test=test.test_concurrent_futures.test_shutdown pid=14246 time=13.1 sec> process group
Kill <WorkerThread #6 running test=test.test_multiprocessing_spawn.test_processes pid=12483 time=33.8 sec> process group
Kill <WorkerThread #4 running test=test_hashlib pid=19110 time=4 ms> process group
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
                     "__main__", mod_spec)
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/runpy.py", line 88, in _run_code
    exec(code, run_globals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/__main__.py", line 2, in <module>
    main(_add_python_opts=True)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 747, in main
    Regrtest(ns, _add_python_opts=_add_python_opts).main(tests=tests)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 739, in main
    exitcode = self.run_tests(selected, tests)
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 576, in run_tests
    return self._run_tests(selected, tests)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 536, in _run_tests
    self._run_tests_mp(runtests, self.num_workers)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 434, in _run_tests_mp
    RunWorkers(num_workers, runtests, self.logger, self.results).run()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/run_workers.py", line 606, in run
    result = self._process_result(item)
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/run_workers.py", line 577, in _process_result
    self.results.accumulate_result(result, self.runtests)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/results.py", line 132, in accumulate_result
    self.add_junit(xml_data)
    ~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/test/libregrtest/results.py", line 165, in add_junit
    self.testsuite_xml.append(ET.fromstring(e))
                              ~~~~~~~~~~~~~^^^
  File "/home/dje/cpython-buildarea/pull_request.edelsohn-sles-z/build/Lib/xml/etree/ElementTree.py", line 1342, in XML
    parser.feed(text)
    ~~~~~~~~~~~^^^^^^
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 8035
make: *** [Makefile:2262: buildbottest] Error 1

Linked PRs

@vstinner
Copy link
Member Author

Extract of the XML: �[?2004h is causing the issue.

<failure type="AssertionError" message="AssertionError: False is not true : (...) for more information.&#13;&#10;&#10;�[?2004h&#10;�[?1h">

@vstinner vstinner added tests Tests in the Lib/test dir topic-XML labels Jun 30, 2024
@vstinner
Copy link
Member Author

Reproducer:

from xml.etree import ElementTree as ET

suite = ET.Element('testsuite')
failure = ET.SubElement(suite, 'failure')
failure.set('message', 'abc \x1b def')

xml_str = ET.tostring(suite).decode('ascii')
print("XML:", ascii(xml_str))

suite2 = ET.fromstring(xml_str)

Output:

XML: '<testsuite><failure message="abc \x1b def" /></testsuite>'
Traceback (most recent call last):
  File "/home/vstinner/python/main/x.py", line 10, in <module>
    suite2 = ET.fromstring(xml_str)
  File "/home/vstinner/python/main/Lib/xml/etree/ElementTree.py", line 1342, in XML
    parser.feed(text)
    ~~~~~~~~~~~^^^^^^
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 33

@vstinner
Copy link
Member Author

cc @serhiy-storchaka

@serhiy-storchaka
Copy link
Member

Unfortunately, XML cannot represent all set of Unicode characters (even in the ASCII range). XML generating code in the stdlib ignores this, producing invalid XML, but the expat parser complains. There are several open issues about this (like #51976). There is no workaround.

In this particular case we can replace unsupported characters before passing them to ElementTree.

@serhiy-storchaka serhiy-storchaka self-assigned this Jul 1, 2024
vstinner added a commit to vstinner/cpython that referenced this issue Jul 1, 2024
When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML such as the chr(27) control character used
in ANSI escape sequences.
vstinner added a commit to vstinner/cpython that referenced this issue Jul 1, 2024
When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML such as the chr(27) control character used
in ANSI escape sequences.
vstinner added a commit to vstinner/cpython that referenced this issue Jul 1, 2024
When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
vstinner added a commit to vstinner/cpython that referenced this issue Jul 1, 2024
When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
@vstinner
Copy link
Member Author

vstinner commented Jul 1, 2024

In this particular case we can replace unsupported characters before passing them to ElementTree.

Good idea. I wrote PR gh-121195 to do that :-)

@serhiy-storchaka
Copy link
Member

Oh, I also wrote a code, but have not create a PR yet due to a power off. Lets compare.

vstinner added a commit that referenced this issue Jul 1, 2024
When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 1, 2024
…H-121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
(cherry picked from commit af8c3d7)

Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 1, 2024
…H-121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
(cherry picked from commit af8c3d7)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner
Copy link
Member Author

vstinner commented Jul 1, 2024

Fixed by af8c3d7.

@vstinner vstinner closed this as completed Jul 1, 2024
vstinner added a commit that referenced this issue Jul 1, 2024
) (#121205)

gh-121188: Sanitize invalid XML characters in regrtest (GH-121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
(cherry picked from commit af8c3d7)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this issue Jul 1, 2024
) (#121204)

gh-121188: Sanitize invalid XML characters in regrtest (GH-121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
(cherry picked from commit af8c3d7)

Co-authored-by: Victor Stinner <vstinner@python.org>
@serhiy-storchaka
Copy link
Member

This is so common problem that I am going to provide standard utility function to handle it in general and efficient way.

Ideas similar to the proposed in #63014 and #67864 can be used here.

Akasurde pushed a commit to Akasurde/cpython that referenced this issue Jul 3, 2024
…121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-XML
Projects
None yet
Development

No branches or pull requests

2 participants