bugfix: using ctypes leads to an exception and premature script exit#47
Open
shshzi wants to merge 3 commits intomanthey:masterfrom
Open
bugfix: using ctypes leads to an exception and premature script exit#47shshzi wants to merge 3 commits intomanthey:masterfrom
shshzi wants to merge 3 commits intomanthey:masterfrom
Conversation
Owner
|
I'd like to have a test that fails before this PR and passes with it. You said that fails, but it works on both appveyor and locally for me. Perhaps it varies based on Windows version? Or I am missing something. |
|
I've been running into this issue as well. It seems to happen under certain contexts so it might work on the same machine in some context, but not in another. If this is the fix, it'd be great to have it added. |
|
I've had this fail while using numpy with "py36-64" on Windows 10.
This produces the same error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is fixing a conflict between the scope of variables in PyInstaller's loader (pyiboot01_bootstrap.py) and Pyexe's tweaking of the globals() dictionary.
The problem can be re-produced by the following python script:
import platform
print(platform.system())
which yields the following (on python 2.7):
Traceback (most recent call last):
File "pyexe.py", line 1236, in
File "pyexe.py", line 1187, in main
File "pyexe.py", line 910, in run_file
File "site-packages\six.py", line 709, in exec_
File "", line 1, in
File "", line 6, in
File "platform.py", line 1265, in system
File "platform.py", line 1161, in uname
File "platform.py", line 637, in win32_ver
File "platform.py", line 592, in _get_real_winver
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 170, in init
NameError: global name '_frozen_name' is not defined
[13452] Failed to execute script pyexe
The problem arises because pyiboot01_bootstrap lazy/late binds variables from the global context (for example: _frozen_name() and imports, such as os). In pyexe.py, all of these variables are then removed from the globals() dictionary (in run_file()), so when some code uses ctypes.WinDLL (which is patched by pyiboot01_bootstrap), these variables cannot be resolved and an exception is emitted.
The simple fix to the problem is to encapsulate all of the relevant code to ctypes in pyiboot01_bootstrap inside a function, to avoid binding to the global context.