Skip to content

Commit

Permalink
depend: work around the potential None referer in get_co_using_ctypes
Browse files Browse the repository at this point in the history
If `ctypes` is (manually) added to hidden imports under python 3.7,
one of `referers` entries processed in `get_co_using_ctypes()` method
of `PyiModuleGraph` ends up being None. This in turn causes error
when its `identifier` property is accessed, causing pyinstaller#3825.

Work around the problem by explicitly skipping `None` entries.

Fixes pyinstaller#3825.
  • Loading branch information
rokm committed Mar 22, 2021
1 parent 8cf796d commit a5c6689
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions PyInstaller/depend/analysis.py
Expand Up @@ -741,6 +741,11 @@ def get_co_using_ctypes(self):
if node:
referers = self.getReferers(node)
for r in referers:
# Under python 3.7 and earlier, if ctypes is added to
# hidden imports, one of referers ends up being None,
# causing #3825. Work around it.
if r is None:
continue
r_ident = r.identifier
# Ensure that modulegraph objects has attribute 'code'.
if type(r).__name__ in pure_python_module_types:
Expand Down
2 changes: 2 additions & 0 deletions news/3825.bugfix.rst
@@ -0,0 +1,2 @@
Fix the build-time error under python 3.7 and earlier when ``ctypes``
is manually added to ``hiddenimports``.

0 comments on commit a5c6689

Please sign in to comment.