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

Regression tests pass but return unnecessary output (errors and warnings) #103186

Closed
TabLand opened this issue Apr 2, 2023 · 11 comments
Closed
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@TabLand
Copy link
Contributor

TabLand commented Apr 2, 2023

Just built python for the first time using the devguide and I noticed some (deprecation) warnings and errors in the regression tests, even though all the tests (that ran) passed.

/opt/python/cpython/Lib/subprocess.py:849: RuntimeWarning: pass_fds overriding close_fds.
  warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
/opt/python/cpython/Lib/http/server.py:1168: DeprecationWarning: This process (pid=55357) is multi-threaded, use of fork() may lead to deadlocks in the child.
/opt/python/cpython/Lib/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=52754) is multi-threaded, use of fork() may lead to deadlocks in the child.
0:07:26 load avg: 8.24 [216/433] test_mailcap passed -- running: test_gdb (2 min 45 sec)
/opt/python/cpython/Lib/mailcap.py:228: UnsafeMailcapInput: Refusing to substitute MIME type 'audio/*' into a shell command.
  warnings.warn(msg, UnsafeMailcapInput)
/opt/python/cpython/Lib/mailcap.py:228: UnsafeMailcapInput: Refusing to substitute MIME type 'audio/*' into a shell command.
  warnings.warn(msg, UnsafeMailcapInput)
/opt/python/cpython/Lib/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=59900) is multi-threaded, use of fork() may lead to deadlocks in the child.
/opt/python/cpython/Lib/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=59550) is multi-threaded, use of fork() may lead to deadlocks in the child.
/opt/python/cpython/Lib/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=62788) is multi-threaded, use of fork() may lead to deadlocks in the child.
/opt/python/cpython/Lib/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=59550) is multi-threaded, use of fork() may lead to deadlocks in the child.
/opt/python/cpython/Lib/test/test_sys_settrace.py:1771: RuntimeWarning: assigning None to 1 unbound local
/opt/python/cpython/Lib/test/test_sys_settrace.py:1771: RuntimeWarning: assigning None to 2 unbound locals
: error: Incorrect number of arguments. uuid3 requires a namespace and a name. Run 'python -m uuid -h' for more information.
: error: Incorrect number of arguments. uuid3 requires a namespace and a name. Run 'python -m uuid -h' for more information.
: error: Incorrect number of arguments. uuid3 requires a namespace and a name. Run 'python -m uuid -h' for more information.
: error: Incorrect number of arguments. uuid3 requires a namespace and a name. Run 'python -m uuid -h' for more information.
0:16:23 load avg: 3.94 [405/433] test_warnings passed -- running: test_tools (59.0 sec)
/opt/python/cpython/Lib/test/test_warnings/__init__.py:390: UserWarning: Other types of warnings are not errors
  self.module.warn("Other types of warnings are not errors")
/opt/python/cpython/Lib/test/test_warnings/__init__.py:390: UserWarning: Other types of warnings are not errors
  self.module.warn("Other types of warnings are not errors")
/opt/python/cpython/Lib/test/test_xxtestfuzz.py:13: DeprecationWarning: module 'sre_compile' is deprecated
/opt/python/cpython/Lib/test/test_xxtestfuzz.py:13: DeprecationWarning: module 'sre_constants' is deprecated
CalledProcessError: Command '['/tmp/test_python_9xherg3o/tmpbgbtwgi2/cpython/python', '-c', 'import sysconfig; print(sysconfig.get_config_var("CONFIG_ARGS"))']' returned non-zero exit status 1.
ModuleNotFoundError: No module named '_sysconfigdata_d_linux_x86_64-linux-gnu'

Will attempt to investigate and patch these where appropriate.
Raising this issue as a base for my first pull request.
Any feedback is welcome!

Linked PRs

@TabLand TabLand added the type-bug An unexpected behavior, bug, or error label Apr 2, 2023
@TabLand
Copy link
Contributor Author

TabLand commented Apr 2, 2023

First challenge, how do I assign this issue to myself?
=D

@TabLand TabLand changed the title Regression tests pass but return noisy output full of errors and warnings Regression tests pass but return unnecessary output (errors and warnings) Apr 2, 2023
@arhadthedev arhadthedev added the tests Tests in the Lib/test dir label Apr 2, 2023
@arhadthedev
Copy link
Member

It's an open project, no preliminary assignment is required.

@TabLand
Copy link
Contributor Author

TabLand commented Apr 2, 2023

test.log

@terryjreedy
Copy link
Member

Thank you for tackling this. Multiple PRs for one issue are allowed and for this issue I would encourage them -- even one for each test file or directory. The commit message, fix strategy and difficulty, possible controversy, reviewer/committers, and backports might vary for each.

@TabLand
Copy link
Contributor Author

TabLand commented Apr 2, 2023

Thanks Terry,

I've managed to find fixes for some of the tests - will raise a few PR's shortly.
Some tests (especially test_sys_settrace - RuntimeWarning: unbound locals ) have been fairly difficult to trace so far.

I'll leave the deprecation warnings for the end; interestingly it's not immediately clear whether newer replacement code exists for all deprecated classes / methods / functions (e.g sre_compile / sre_constants)

@TabLand
Copy link
Contributor Author

TabLand commented Apr 3, 2023

I've made some progress in tracing this error under test_tools.test_freeze_simple_script:

# /opt/python/test/cpython/python -c 'import sysconfig; print(sysconfig.get_config_var("CONFIG_ARGS"))'
CalledProcessError: Command '['/opt/python/test/cpython/python', '-c', 'import sysconfig; print(sysconfig.get_config_var("CONFIG_ARGS"))']' returned non-zero exit status 1.
--- STDOUT ---

--- STDERR ---
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/python/test/cpython/Lib/sysconfig.py", line 740, in get_config_var
    return get_config_vars().get(name)
           ^^^^^^^^^^^^^^^^^
  File "/opt/python/test/cpython/Lib/sysconfig.py", line 723, in get_config_vars
    _init_config_vars()
  File "/opt/python/test/cpython/Lib/sysconfig.py", line 670, in _init_config_vars
    _init_posix(_CONFIG_VARS)
  File "/opt/python/test/cpython/Lib/sysconfig.py", line 536, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_sysconfigdata_d_linux_x86_64-linux-gnu'

This is caused by the following file being unavailable in the intermediate build, despite being copied:
/opt/python/test/cpython/build/lib.linux-x86_64-3.12-pydebug/_sysconfigdata_d_linux_x86_64-linux-gnu.py

Looks like a timing issue in Tools/freeze/test/freeze.py where make clean is called before the CONFIG_ARGS lookup against the intermediate frozen build - it looks like this lookup depends on the build being complete. Will prep a change for this shortly (fetch this info from the original instead of the intermediate build)

@arhadthedev
Copy link
Member

Closing as a duplicate of (now fixed) gh-102151.

@arhadthedev
Copy link
Member

arhadthedev commented Apr 6, 2023

Reopening because I didn't notice there are three more attached PRs.

@arhadthedev arhadthedev reopened this Apr 6, 2023
warsaw pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
terryjreedy pushed a commit that referenced this issue Jul 10, 2023
Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 10, 2023
…ythonGH-103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

(cherry picked from commit 9d58225)

Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
terryjreedy added a commit to terryjreedy/cpython that referenced this issue Jul 10, 2023
…ests (python#103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
(cherry picked from commit 9d58225)
terryjreedy pushed a commit that referenced this issue Jul 10, 2023
…H-103196) (#106605)

gh-103186: Fix or catch 'extra' stderr output from unittests (GH-103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

(cherry picked from commit 9d58225)

Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
terryjreedy added a commit that referenced this issue Jul 10, 2023
…103196) (#106606)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
(cherry picked from commit 9d58225)
erlend-aasland pushed a commit that referenced this issue Jul 11, 2023
…ce directory (#103213)

Fetch CONFIG_ARGS from the original source directory, instead of from
the copied source tree. When "make clean" is executed in the copied
source tree, the build directory is cleared and the configure argument
lookup fails. However, the original source directory still contains this
information.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 12, 2023
…l source directory (pythonGH-103213)

Fetch CONFIG_ARGS from the original source directory, instead of from
the copied source tree. When "make clean" is executed in the copied
source tree, the build directory is cleared and the configure argument
lookup fails. However, the original source directory still contains this
information.
(cherry picked from commit de82732)

Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
serhiy-storchaka pushed a commit that referenced this issue Sep 7, 2023
…ettrace (GH-103244)

Caused as a result of frame manipulation where locals are never assigned / initialised.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 7, 2023
…_sys_settrace (pythonGH-103244)

Caused as a result of frame manipulation where locals are never assigned / initialised.
(cherry picked from commit 3e53ac9)

Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 7, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 7, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 7, 2023
…9077)

(cherry picked from commit e4bb002)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 7, 2023
…9077)

(cherry picked from commit e4bb002)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 7, 2023
…iterator in test_sys_settrace (pythonGH-109075).

(cherry picked from commit d485551)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Sep 7, 2023
…GH-109085)

(cherry picked from commit e4bb002)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Sep 7, 2023
@serhiy-storchaka
Copy link
Member

Opened separate issues #109096 (non-trivial, needs discussion) and #109098 (may be easy, but may need familiarity with the subject).

@TabLand
Copy link
Contributor Author

TabLand commented Sep 7, 2023

Thank you for sharing!
I'll try and have a brief look into these...

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Sep 7, 2023
Print additional details only when tests are run with -vv.
serhiy-storchaka added a commit that referenced this issue Sep 7, 2023
Print additional details only when tests are run with -vv.
Yhg1s pushed a commit that referenced this issue Sep 8, 2023
…t_sys_settrace (GH-103244) (#109066)

gh-103186: Suppress and assert expected RuntimeWarnings in test_sys_settrace (GH-103244)

Caused as a result of frame manipulation where locals are never assigned / initialised.
(cherry picked from commit 3e53ac9)

Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
Yhg1s pushed a commit that referenced this issue Sep 8, 2023
…#109084)

gh-103186: Remove debug print in test_sys_settrace (GH-109077)
(cherry picked from commit e4bb002)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 8, 2023
…r in test_sys_settrace (pythonGH-109075)

(cherry picked from commit d485551)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Yhg1s pushed a commit that referenced this issue Sep 8, 2023
…or in test_sys_settrace (GH-109075) (#109138)

gh-103186: Suppress RuntimeWarning about unclosed async iterator in test_sys_settrace (GH-109075)
(cherry picked from commit d485551)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@TabLand
Copy link
Contributor Author

TabLand commented Oct 3, 2023

Hi Team,
It's probably safe to close this issue as all the original warnings no longer appear in the latest build.
However, there are some new warnings I've seen in the latest build, will log a new issue to track and tackle them.

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 type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants