]> granicus.if.org Git - python/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:05:24 +0000 (14:05 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 29 Jul 2002 14:05:24 +0000 (14:05 +0000)
of encodings. Skip modules that don't have a getregentry function.

Lib/encodings/__init__.py

index ca59721222530351d68598baa2732b82875e1e96..e3b97aed833c6ab2313ed610de25d3ead4e47878 100644 (file)
@@ -55,24 +55,27 @@ def search_function(encoding):
     try:
         mod = __import__('encodings.' + modname,
                          globals(), locals(), _import_tail)
-    except ImportError,why:
+    except ImportError:
         import aliases
         modname = aliases.aliases.get(modname, modname)
         try:
-            mod = __import__('encodings.' + modname, globals(), locals(), _import_tail)
-        except ImportError,why:
+            mod = __import__(modname, globals(), locals(), _import_tail)
+        except ImportError:
             mod = None
+
+    try:
+        getregentry = mod.getregentry
+    except AttributeError:
+        # Not a codec module
+        mod = None
+
     if mod is None:
         # Cache misses
         _cache[encoding] = None
-        return None
-        
+        return None    
     
     # Now ask the module for the registry entry
-    try:
-        entry = tuple(mod.getregentry())
-    except AttributeError:
-        entry = ()
+    entry = tuple(getregentry())
     if len(entry) != 4:
         raise CodecRegistryError,\
               'module "%s" (%s) failed to register' % \