From 4d9b4887f15a86ae1cbf0825a8c4b89655b41f63 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 24 Jan 2020 09:22:16 -0700 Subject: [PATCH 1/2] bpo-8901: Windows registry path not ignored with the -E option --- .../next/Windows/2020-01-24-09-15-41.bpo-8901.hVnhGO.rst | 1 + PC/getpathp.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Windows/2020-01-24-09-15-41.bpo-8901.hVnhGO.rst diff --git a/Misc/NEWS.d/next/Windows/2020-01-24-09-15-41.bpo-8901.hVnhGO.rst b/Misc/NEWS.d/next/Windows/2020-01-24-09-15-41.bpo-8901.hVnhGO.rst new file mode 100644 index 00000000000000..1d452cf26297f8 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2020-01-24-09-15-41.bpo-8901.hVnhGO.rst @@ -0,0 +1 @@ +Ignore the Windows registry when the ``-E`` option is used. diff --git a/PC/getpathp.c b/PC/getpathp.c index 085caf195a9920..f7f09c65744a31 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -829,8 +829,11 @@ calculate_module_search_path(PyCalculatePath *calculate, { int skiphome = calculate->home==NULL ? 0 : 1; #ifdef Py_ENABLE_SHARED - calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); - calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome); + if (!Py_IgnoreEnvironmentFlag) { + calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, + skiphome); + calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome); + } #endif /* We only use the default relative PYTHONPATH if we haven't anything better to use! */ From 1183abf096be1066a77d246b2198011834007340 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 28 Mar 2020 08:07:45 -0600 Subject: [PATCH 2/2] Add an entry in What's New. --- Doc/whatsnew/3.9.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 778e443f8d0777..9d4707f593459a 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -543,6 +543,11 @@ Build and C API Changes * The :c:func:`PyModule_AddType` function is added to help adding a type to a module. (Contributed by Dong-hee Na in :issue:`40024`.) +* The Windows registry is no longer used to initialize :data:`sys.path` when + the ``-E`` option is used. This is significant when embedding Python on + Windows. + (Contributed by Zackery Spytz in :issue:`8901`.) + Deprecated ==========