From 7329503535ad4ce1b29af801b0d1db015a727553 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 29 Jul 2002 14:04:36 +0000 Subject: [PATCH] Revert #571603 since it is ok to import codecs that are not subdirectories of encodings. Skip modules that don't have a getregentry function. --- Lib/encodings/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py index 06817d6fdd63..dcc72bb5ea4c 100644 --- a/Lib/encodings/__init__.py +++ b/Lib/encodings/__init__.py @@ -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: -- 2.47.3