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: python.exe crashes if it is unable to find its .dll
Type: Stage:
Components: Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, christian.heimes, georg.brandl, techtonik
Priority: normal Keywords:

Created on 2011-05-17 19:12 by techtonik, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (9)
msg136173 - (view) Author: anatoly techtonik (techtonik) Date: 2011-05-17 19:12
On Windows, if Python is unable to find its .dll it crashes badly. This affects `vurtualenv` project that doesn't copy .dll file. It would be more user friendly if python.exe launcher could detect this situation and fail gracefully.

Such kind of dynamic linking can also serve as an example for building launchers for applications that optionally provide Python scripting depending on if Python .dll is present on the system.

And the ultimate launcher will allow to load any available .dll  This can be extremely handy for apps with embedded Python that use scripts compatible with Python 2.5+
msg136176 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-05-17 20:19
Which dll was missing in your case? python27.dll, python32.dll or another one?
Virtualenv usually work on Windows. What did it fail to copy?

There is already PEP387 about a "Python launcher" on Windows. Can you please read the specifications, and tell us if they would fit your needs?
msg136202 - (view) Author: anatoly techtonik (techtonik) Date: 2011-05-18 03:58
pythonXX.dll is missing. Virtualenv copies python.exe, which is only 25kB long. It works only if pythonXX.dll is present in system PATH - either installed into Windows\System32 or comes with Mercurial, Bazaar or other frozen app install.
msg136203 - (view) Author: anatoly techtonik (techtonik) Date: 2011-05-18 04:18
As for PEPs I think you've meant PEP 397 http://www.python.org/dev/peps/pep-0397/ which is tl; dr for the moment.
msg136205 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-05-18 05:48
Virtualenv only works with an installed Python. This is really a virtualenv limitation, then; your issue looks similar to this one:
https://github.com/pypa/virtualenv/issues/87
msg136207 - (view) Author: anatoly techtonik (techtonik) Date: 2011-05-18 07:47
Reopening as I believe the issue is hijacked. Virtualenv is just an example and the fix is discussed on its mailing list.

This issue is about that Python interpreter is not self-contained, not portable, i.e. split into python.exe and pythonXX.dll The only reason for this split is to allow other programs use dynamic linking to load interpreter from .dll Such programs even though they are using pythonXX.dll from different .exe file do not crash. python.exe should not crash also. Moreover - as an open source project - it should serve as an example of proper linking to Python.

It is not covered by PEP 397, because PEP is about launcher that chooses among multiple Python versions and this request about command line launcher for specific Python interpreter. But PEP 397 still can benefit from the research on this feature request - like explaining linking mechanism for developers.
msg136210 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-05-18 08:01
You are right, the use case is broader than virtualenv.

> The only reason for this split is to allow other programs use dynamic linking
For me the main reason is to support extension modules. On Windows, a DLL (or a .pyd) cannot resolve symbols in the main .exe program.

Do you have more specifications about such a launcher? How would it find the .dll?
msg136213 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-05-18 08:26
And most importantly, what would it do if the .dll is not found?  What can it do, other than present a message box "Cannot find pythonXY.dll, exiting."
msg192670 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-08 16:58
'We' don't show any error message. Windows does it on its own because the pythonXX.dll is a dependency for the executable.

If python.exe can't find the DLL then it's also likely that the DLL is unable to find Python's stdlib. Python requires the stdlib to run, too. There isn't much we can do about that.
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56306
2013-07-08 16:58:34christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg192670

resolution: rejected
2011-05-18 08:26:50georg.brandlsetnosy: + georg.brandl
messages: + msg136213
2011-05-18 08:01:17amaury.forgeotdarcsetmessages: + msg136210
2011-05-18 07:47:12techtoniksetstatus: closed -> open
resolution: not a bug -> (no value)
messages: + msg136207
2011-05-18 05:48:21amaury.forgeotdarcsetstatus: open -> closed
resolution: not a bug
messages: + msg136205
2011-05-18 04:18:53techtoniksetmessages: + msg136203
2011-05-18 03:58:35techtoniksetmessages: + msg136202
2011-05-17 20:19:08amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg136176
2011-05-17 19:12:07techtonikcreate