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_copyreg: importing numpy changes warnings filters
Type: Stage: resolved
Components: Tests Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2020-06-17 12:45 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20935 merged vstinner, 2020-06-17 13:12
PR 20945 merged vstinner, 2020-06-17 16:18
PR 20946 merged vstinner, 2020-06-17 16:42
Messages (5)
msg371736 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-17 12:45
This issue is similar to bpo-40055: running test_copyreg fails with ENV_CHANGED if numpy is available. Example:

$ ./python -m venv env
$ env/bin/python -m pip install numpy
$ env/bin/python -m test --fail-env-changed -v test_copyreg -m xxxx
== CPython 3.9.0b3+ (heads/getpath_platlibdir39:11462e9847, Jun 11 2020, 17:49:13) [GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
(...)
Warning -- warnings.filters was modified by test_copyreg
  Before: (140498488250848, [], [])
  After:  (140498488250848, [], [('ignore', re.compile('numpy.ndarray size changed', re.IGNORECASE), <class 'Warning'>, None, 0), ('ignore', re.compile('numpy.ufunc size changed', re.IGNORECASE), <class 'Warning'>, None, 0), ('ignore', re.compile('numpy.dtype size changed', re.IGNORECASE), <class 'Warning'>, None, 0), ('always', None, <class 'numpy.RankWarning'>, None, 0)]) 
(...)
msg371737 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-17 13:08
The issue can be replaced by a fake numpy module:

$ cat Lib/numpy.py 
import warnings
warnings.simplefilter('ignore', UserWarning)
msg371756 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-17 16:07
New changeset 8362893e3fe083df2ec8bb94c28b1a78383eadbf by Victor Stinner in branch 'master':
bpo-41003: Fix test_copyreg when numpy is installed (GH-20935)
https://github.com/python/cpython/commit/8362893e3fe083df2ec8bb94c28b1a78383eadbf
msg371760 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-17 16:40
New changeset b39d41ba1b77f7bc51c4d6f6d0e336693192cb3a by Victor Stinner in branch '3.9':
bpo-41003: Fix test_copyreg when numpy is installed (GH-20935) (GH-20945)
https://github.com/python/cpython/commit/b39d41ba1b77f7bc51c4d6f6d0e336693192cb3a
msg371764 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-17 17:09
New changeset 3d974b2fc681ddd0ec722cf631008d5941da52b8 by Victor Stinner in branch '3.8':
bpo-41003: Fix test_copyreg when numpy is installed (GH-20935) (GH-20945) (GH-20946)
https://github.com/python/cpython/commit/3d974b2fc681ddd0ec722cf631008d5941da52b8
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85175
2020-06-17 17:10:24vstinnersetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.8, Python 3.9
2020-06-17 17:09:56vstinnersetmessages: + msg371764
2020-06-17 16:42:50vstinnersetpull_requests: + pull_request20127
2020-06-17 16:40:23vstinnersetmessages: + msg371760
2020-06-17 16:18:11vstinnersetpull_requests: + pull_request20126
2020-06-17 16:07:28vstinnersetmessages: + msg371756
2020-06-17 13:12:43vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request20114
2020-06-17 13:08:41vstinnersetmessages: + msg371737
2020-06-17 12:45:57vstinnercreate