Skip to content

Commit

Permalink
loader: prevent local directory from shadowing system library (#5182)
Browse files Browse the repository at this point in the history
* loader: prevent local directory from shadowing system library

When loading a system dynamic library via ctypes.CDLL() in a
frozen progam, a local directory in sys._MEIPASS with a clashing
basename ends up preventing the library from being loaded.

To fix this, use an os.path.isdir() to decide whether to use
frozen or original library name.

Fixes #5178.

* Added news fragment for PR.
  • Loading branch information
rokm committed Sep 22, 2020
1 parent 9001222 commit bfc8b08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PyInstaller/loader/pyiboot01_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def isatty(self):
def _frozen_name(name):
if name:
frozen_name = os.path.join(sys._MEIPASS, os.path.basename(name))
if os.path.exists(frozen_name):
if os.path.exists(frozen_name) and not os.path.isdir(frozen_name):
name = frozen_name
return name

Expand Down
1 change: 1 addition & 0 deletions news/5182.core.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent a local directory with clashing name from shadowing a system library.

0 comments on commit bfc8b08

Please sign in to comment.