mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45211: Remember the stdlib dir during startup. (gh-28586)
During runtime startup we figure out the stdlib dir but currently throw that information away. This change preserves it and exposes it via PyConfig.stdlib_dir, _Py_GetStdlibDir(), and sys._stdlib_dir. https://bugs.python.org/issue45211
This commit is contained in:
parent
84975146a7
commit
0c50b8c0b8
10 changed files with 93 additions and 3 deletions
|
@ -13,6 +13,7 @@ from test import support
|
|||
from test.support import os_helper
|
||||
from test.support.script_helper import assert_python_ok, assert_python_failure
|
||||
from test.support import threading_helper
|
||||
from test.support import import_helper
|
||||
import textwrap
|
||||
import unittest
|
||||
import warnings
|
||||
|
@ -994,6 +995,15 @@ class SysModuleTest(unittest.TestCase):
|
|||
for name in sys.stdlib_module_names:
|
||||
self.assertIsInstance(name, str)
|
||||
|
||||
def test_stdlib_dir(self):
|
||||
os = import_helper.import_fresh_module('os')
|
||||
marker = getattr(os, '__file__', None)
|
||||
if marker and not os.path.exists(marker):
|
||||
marker = None
|
||||
expected = os.path.dirname(marker) if marker else None
|
||||
actual = sys._stdlib_dir
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
|
||||
@test.support.cpython_only
|
||||
class UnraisableHookTest(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue