File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1313from test .support import os_helper
1414from test .support .script_helper import assert_python_ok , assert_python_failure
1515from test .support import threading_helper
16+ from test .support import import_helper
1617import textwrap
1718import unittest
1819import warnings
@@ -994,6 +995,15 @@ def test_module_names(self):
994995 for name in sys .stdlib_module_names :
995996 self .assertIsInstance (name , str )
996997
998+ def test_stdlib_dir (self ):
999+ os = import_helper .import_fresh_module ('os' )
1000+ marker = getattr (os , '__file__' , None )
1001+ if marker and not os .path .exists (marker ):
1002+ marker = None
1003+ expected = os .path .dirname (marker ) if marker else None
1004+ actual = sys ._stdlib_dir
1005+ self .assertEqual (actual , expected )
1006+
9971007
9981008@test .support .cpython_only
9991009class UnraisableHookTest (unittest .TestCase ):
Original file line number Diff line number Diff line change @@ -2974,6 +2974,14 @@ _PySys_UpdateConfig(PyThreadState *tstate)
29742974
29752975 SET_SYS ("_xoptions" , sys_create_xoptions_dict (config ));
29762976
2977+ const wchar_t * stdlibdir = _Py_GetStdlibDir ();
2978+ if (stdlibdir != NULL ) {
2979+ SET_SYS_FROM_WSTR ("_stdlib_dir" , stdlibdir );
2980+ }
2981+ else {
2982+ PyDict_SetItemString (sysdict , "_stdlib_dir" , Py_None );
2983+ }
2984+
29772985#undef SET_SYS_FROM_WSTR
29782986#undef COPY_LIST
29792987#undef COPY_WSTR
You can’t perform that action at this time.
0 commit comments