]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Revert #571603 since it is ok to import codecs that are not subdirectories
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 29 Jul 2002 14:04:36 +0000 (14:04 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 29 Jul 2002 14:04:36 +0000 (14:04 +0000)
of encodings. Skip modules that don't have a getregentry function.

Lib/encodings/__init__.py

index 06817d6fdd6311ddc1574d378234f8a3131d38e4..dcc72bb5ea4c01e752fcd8f31204c4320b105e3f 100644 (file)
@@ -48,15 +48,22 @@ def search_function(encoding):
     modname = encoding.replace('-', '_')
     modname = aliases.aliases.get(modname,modname)
     try:
-        mod = __import__('encodings.'+modname,globals(),locals(),'*')
+        mod = __import__(modname,globals(),locals(),'*')
     except ImportError,why:
         # cache misses
         _cache[encoding] = None
         return None
+
+    try:
+        getregentry = mod.getregentry
+    except AttributeError:
+        # Not a codec module
+        _cache[encoding] = None
+        return None
     
     # Now ask the module for the registry entry
     try:
-        entry = tuple(mod.getregentry())
+        entry = tuple(getregentry())
     except AttributeError:
         entry = ()
     if len(entry) != 4: