forked from pyinstaller/pyinstaller
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pyinstaller#2492: Crash if extension module has hidden import to …
…ctypes. Includes regression test.
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#----------------------------------------------------------------------------- | ||
# Copyright (c) 2005-2017, PyInstaller Development Team. | ||
# | ||
# Distributed under the terms of the GNU General Public License with exception | ||
# for distributing bootloader. | ||
# | ||
# The full license is in the file COPYING.txt, distributed with this software. | ||
#----------------------------------------------------------------------------- | ||
|
||
|
||
import pytest | ||
import py.path | ||
|
||
from PyInstaller.depend import analysis | ||
from PyInstaller.building.build_main import Analysis | ||
|
||
def test_issue_2492(monkeypatch, tmpdir): | ||
# Crash if an extension module has an hidden import to ctypes (e.g. added | ||
# by the hook). | ||
|
||
# Need to set up some values | ||
monkeypatch.setattr('PyInstaller.config.CONF', | ||
{'workpath': str(tmpdir), | ||
'spec': str(tmpdir), | ||
'warnfile': str(tmpdir.join('warn.txt')), | ||
'hiddenimports': []}) | ||
# Speedup: avoid analyzing base_library.zip | ||
monkeypatch.setattr(analysis, 'PY3_BASE_MODULES', []) | ||
|
||
script = tmpdir.join('script.py') | ||
script.write('import _struct') | ||
# create a hook | ||
tmpdir.join('hook-_struct.py').write('hiddenimports = ["ctypes"]') | ||
a = Analysis([str(script)], hookspath=[str(tmpdir)], | ||
excludes=['encodings', 'pydoc', 'xml', 'distutils']) |