homepage

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.script_helper should copy SYSTEMROOT environment variable for __cleanenv=True
Type: Stage: needs patch
Components: Tests Versions: Python 3.3, Python 3.4, Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, serhiy.storchaka, tim.golden, vstinner
Priority: normal Keywords: patch

Created on 2014年02月13日 10:26 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cleanenv.patch vstinner, 2014年02月13日 10:27 review
Messages (8)
msg211138 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年02月13日 10:26
On Windows, if Python is started with an empty environment (no environment variable at all), Python fails with:
"Fatal Python error: Failed to initialize Windows random API (CryptoGen)"
It's the Windows error 0x80090006 which is not displayed in the error message :-(
In fact, it's because Python 3 cannot be started without SYSTEMROOT environment variable. Otherwise, CryptAcquireContext() is unable to find some DLL.
IMO the script_helper should be fixed to copy the variable.
Recent example of this issue:
http://bugs.python.org/issue20599#msg211111 
msg211139 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年02月13日 10:27
cleanenv.patch: untested test.
msg211141 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年02月13日 10:37
When Python is executed in an empty environement, not only it displays "Fatal Python error: Failed to initialize Windows random API (CryptoGen)", but it opens also the fatal error popup on Windows.
The issue #19983 proposes a patch to not abort() at exit, but exit with an non-zero exit code instead. The same should be done for this error.
By the way, we can maybe help the use to fix this issue with a better error message. For example, add in the message " (check if SYSTEMROOT environment variable is correctly set)", maybe only if the environment variable is not set.
msg211143 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年02月13日 10:51
Oh, another problem: if Python is compiled in shared module, libpython3.4.so cannot be found. LD_LIBRARY_PATH must also be copied if __cleanenv=True. Py_ENABLE_SHARED can be checked in sysconfig to decide if the environment variable should be copied or not.
msg211295 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014年02月15日 20:46
Interesting, how isolation mode works on Windows or if Python is compiled in shared module? Should we keep these environment variables if the __isolated keyword is used?
msg211304 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2014年02月16日 01:57
> Oh, another problem: if Python is compiled in shared module, libpython3.4.so cannot be found.
> LD_LIBRARY_PATH must also be copied if __cleanenv=True. Py_ENABLE_SHARED can be checked in
> sysconfig to decide if the environment variable should be copied or not.
The name of variable is specific to operating system.
Potentially incomplete list based on value of RUNSHARED variable in configure.ac:
 AIX: LIBPATH
 HP-UX: SHLIB_PATH
 Linux, GNU Hurd, *BSD, SunOS: LD_LIBRARY_PATH
 Mac OS X (with --enable-shared): DYLD_LIBRARY_PATH
 Mac OS X (with --disable-shared and --enable-framework): DYLD_FRAMEWORK_PATH
msg211369 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年02月16日 22:58
Serhiy> Interesting, how isolation mode works on Windows or if Python is compiled in shared module? Should we keep these environment variables if the __isolated keyword is used?
The __isolated parameter of script_helper._assert_python() don't start Python with an empty environment, it only adds -I to the command line.
There is a single test which uses __cleanenv=True: test_hash.
Arfrever> The name of variable is specific to operating system.
Ah yes, right. It's probably safe to copy all these environment variables without taking care of the operating system.
msg238432 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015年03月18日 13:25
> There is a single test which uses __cleanenv=True: test_hash.
The test pass on Windows and this issue is old. I prefer to simplify close it.
History
Date User Action Args
2022年04月11日 14:57:58adminsetgithub: 64813
2015年03月18日 13:25:42vstinnersetstatus: open -> closed
resolution: out of date
messages: + msg238432
2014年02月16日 23:03:03brian.curtinsetnosy: - brian.curtin
2014年02月16日 22:58:10vstinnersetmessages: + msg211369
2014年02月16日 01:57:05Arfreversetnosy: + Arfrever
messages: + msg211304
2014年02月15日 20:46:51serhiy.storchakasetmessages: + msg211295
2014年02月13日 19:01:12serhiy.storchakasetstage: needs patch
2014年02月13日 10:51:02vstinnersetmessages: + msg211143
2014年02月13日 10:37:51vstinnersetmessages: + msg211141
2014年02月13日 10:27:26vstinnersetfiles: + cleanenv.patch
keywords: + patch
messages: + msg211139
2014年02月13日 10:26:05vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /