summaryrefslogtreecommitdiffstats
path: root/Lib/encodings/__init__.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-07-29 14:05:24 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-07-29 14:05:24 (GMT)
commitb9e0764d8bc610d90d5aed9d8a97fe7643a2eeec (patch)
treefa2a901d58da2a7b220d7c291d8354910b7dd113 /Lib/encodings/__init__.py
parenta2905273766bbbebb87274c87b62772cdfaeb180 (diff)
downloadcpython-b9e0764d8bc610d90d5aed9d8a97fe7643a2eeec.zip
cpython-b9e0764d8bc610d90d5aed9d8a97fe7643a2eeec.tar.gz
cpython-b9e0764d8bc610d90d5aed9d8a97fe7643a2eeec.tar.bz2
Revert #571603 since it is ok to import codecs that are not subdirectories
of encodings. Skip modules that don't have a getregentry function.
Diffstat (limited to 'Lib/encodings/__init__.py')
-rw-r--r--Lib/encodings/__init__.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index ca59721..e3b97ae 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -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' % \