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_buffer altered the execution environment
Type: resource usage Stage: resolved
Components: Tests Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, michael.foord, serhiy.storchaka, skrah, vstinner
Priority: normal Keywords: patch

Created on 2017-10-15 09:35 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4007 merged serhiy.storchaka, 2017-10-15 12:44
PR 4009 merged python-dev, 2017-10-16 07:38
Messages (14)
msg304426 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-15 09:35
test_buffer adds two environment variables: 'OPENBLAS_MAIN_FREE': '1', 'GOTOBLAS_MAIN_FREE': '1'.

$ ./python -m test -v test_buffer
...
Warning -- os.environ was modified by test_buffer
  Before: (140174267697792, environ({...})
  After:  (140174267697792, environ({..., 'OPENBLAS_MAIN_FREE': '1', 'GOTOBLAS_MAIN_FREE': '1'}) 
test_buffer failed (env changed)

1 test altered the execution environment:
    test_buffer

Total duration: 8 sec
Tests result: SUCCESS
msg304428 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-15 09:41
Why the env changed wasn't noticed before? Is it a recent change?
msg304430 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-15 10:08
I just have installed NumPy. It temporary sets these two environment variables for importing the multiarray numpy extension module, but forgot to remove them if the import is failed.

test_buffer imports numpy.

try:
    with warnings.catch_warnings():
        from numpy import ndarray as numpy_array
except ImportError:
    numpy_array = None
msg304432 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-10-15 11:27
So it is a numpy issue? Which numpy version is it?
msg304434 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-15 11:48
It is particularly a NumPy issue (I have opened a bug https://github.com/numpy/numpy/issues/9861). It is exposed because I have installed NumPy with non-debug build of CPython and run the test with debug build of CPython. The test is passes with non-debug build of CPython. I am wondering if we can make a workaround and if we should do this.
msg304435 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-10-15 12:01
Thanks. If it only occurs when mixing debug/non-debug I don't think we have to do anything about it.
msg304436 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-15 12:13
I suggest to always save/restore env vars on numpy import, since we don't
control 3rd party code.
msg304437 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-10-15 12:26
That's fine.
msg304438 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-10-15 13:13
I can't figure out how to make the damn button green on GitHub,
so LGTM. :)
msg304441 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-15 17:49
The issue is fixed on NumPy side (will be included in the next release). Is the workaround on our side still needed?
msg304442 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-10-15 17:56
I'd push it so we don't have to worry about similar things in the
future.  The "warnings.catch_warnings()" thing is also a workaround
for some past numpy release.
msg304455 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-16 07:38
New changeset 676db4bbf2e7c18dc7c35add17dd3bbdc2d3eeb3 by Serhiy Storchaka in branch 'master':
bpo-31792: Restore os.environ in test_buffer when import numpy. (#4007)
https://github.com/python/cpython/commit/676db4bbf2e7c18dc7c35add17dd3bbdc2d3eeb3
msg304460 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-16 08:21
New changeset 06949585d292d1a9dbf2d0d0fa8fc8fe1dee3ccf by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31792: Restore os.environ in test_buffer when import numpy. (GH-4007) (#4009)
https://github.com/python/cpython/commit/06949585d292d1a9dbf2d0d0fa8fc8fe1dee3ccf
msg304461 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-16 08:22
Thank you Victor and Stefan for your review.
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75973
2017-10-16 08:22:33serhiy.storchakasetstatus: open -> closed
versions: + Python 3.6, Python 3.7, - Python 3.8
messages: + msg304461

resolution: fixed
stage: patch review -> resolved
2017-10-16 08:21:35serhiy.storchakasetmessages: + msg304460
2017-10-16 07:38:26python-devsetpull_requests: + pull_request3983
2017-10-16 07:38:17serhiy.storchakasetmessages: + msg304455
2017-10-15 17:56:15skrahsetmessages: + msg304442
2017-10-15 17:49:26serhiy.storchakasetmessages: + msg304441
2017-10-15 13:13:41skrahsetmessages: + msg304438
2017-10-15 12:44:36serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request3981
2017-10-15 12:26:55skrahsetmessages: + msg304437
2017-10-15 12:13:08vstinnersetmessages: + msg304436
2017-10-15 12:01:32skrahsetmessages: + msg304435
2017-10-15 11:48:49serhiy.storchakasetmessages: + msg304434
2017-10-15 11:27:52skrahsetmessages: + msg304432
versions: + Python 3.8, - Python 3.6, Python 3.7
2017-10-15 10:08:56serhiy.storchakasetmessages: + msg304430
2017-10-15 09:41:42vstinnersetmessages: + msg304428
2017-10-15 09:35:57serhiy.storchakacreate