diff --git a/PyInstaller/depend/analysis.py b/PyInstaller/depend/analysis.py index b4f87b31f5..c33dc446f3 100644 --- a/PyInstaller/depend/analysis.py +++ b/PyInstaller/depend/analysis.py @@ -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: diff --git a/news/3825.bugfix.rst b/news/3825.bugfix.rst new file mode 100644 index 0000000000..94d84192cc --- /dev/null +++ b/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``.