]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF #841977 - modulefinder fails to find extension modules in packages
authorThomas Heller <theller@ctypes.org>
Fri, 14 Nov 2003 10:23:03 +0000 (10:23 +0000)
committerThomas Heller <theller@ctypes.org>
Fri, 14 Nov 2003 10:23:03 +0000 (10:23 +0000)
The find_all_submodules() method in modulefinder only
looks for *.py, *.pyc, and *.pyo files.  Python
extension modules are only found if they are referenced
in import statements somewhere.

This patch uses the actual list from imp.get_suffixes().

Backported to release-maint23.

Lib/modulefinder.py

index be59f97f2bc88bde357f969e69289535f67d416a..6dec0e5903d971c3b032fb03fd3aba4fcc283620 100644 (file)
@@ -210,7 +210,12 @@ class ModuleFinder:
         if not m.__path__:
             return
         modules = {}
-        suffixes = [".py", ".pyc", ".pyo"]
+        # 'suffixes' used to be a list hardcoded to [".py", ".pyc", ".pyo"].
+        # But we must also collect Python extension modules - although
+        # we cannot separate normal dlls from Python extensions.
+        suffixes = []
+        for triple in imp.get_suffixes():
+            suffixes.append(triple[0])
         for dir in m.__path__:
             try:
                 names = os.listdir(dir)