Skip to content

Python 3.11.0 -> 3.11.1 : ...\Python311\DLLs not added to sys.path in embedded startup on Windows #100320

Closed
@kxrob

Description

@kxrob

Bug report

When updating Python 3.11.0 -> 3.11.1 (or reverse to reverse the issue), the ...\Python311\DLLs folder is suddenly not added anymore to sys.path in embedded startup due to somehow impaired search path algorithm. E.g. in Pythonwin.exe. And thus things like ctypes, socket, hashlib etc. cannot be imported. But ...\Python311\Lib and all the other paths are correctly there, just the DLLs path missing.

The same was observed e.g. here:
mhammond/pywin32#1995

The issue is also in current Py 3.12.0a3 at least.
The issue seems not to be with python.exe startup.
The issue also disappears when I monkey-copy the Pythonwin.exe next to python.exe and use that copy.

Note: Pythonwin.exe locates pythonNN.dll dynamically and does the usual Python init.

And extra confusing: in the registry there is a PythonPath key like C:\Python312\Lib\;C:\Python312\DLLs\ :
I always thought that the DLLs path is taken from there. But when I edit-damage that like C:\Python312\Lib\;C:\Python312\DLLsx\ e.g., it has no effect :-)
The correct DLLs dir (only) is still in the sys.path in the above working cases, and DLLsx also does not appear on sys.path in the non-working cases.

Reproduce:

  • Win10
  • pip install pywin32; run Pythonwin.exe
  • import ctypes and/or inspect sys.path after start.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesOS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions