summaryrefslogtreecommitdiffstats
path: root/Lib/encodings
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2001-09-19 11:52:07 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2001-09-19 11:52:07 (GMT)
commit816a1b75b76b9b6cb74c3ea43508e3507491638e (patch)
tree78780a7398297fe1f40d8e3b81aaafe13fdbaa97 /Lib/encodings
parent494f2aea8e56a73012f7aeb31ecdd14b13c6da59 (diff)
downloadcpython-816a1b75b76b9b6cb74c3ea43508e3507491638e.zip
cpython-816a1b75b76b9b6cb74c3ea43508e3507491638e.tar.gz
cpython-816a1b75b76b9b6cb74c3ea43508e3507491638e.tar.bz2
Fixed search function error reporting in the encodings package
__init__.py module to raise errors which can be catched as LookupErrors as well as SystemErrors. Modified the error messages to include more information about the failing module.
Diffstat (limited to 'Lib/encodings')
-rw-r--r--Lib/encodings/__init__.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index 51ec873..3830954 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -28,11 +28,15 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""#"
-import codecs,aliases
+import codecs,aliases,exceptions
_cache = {}
_unknown = '--unknown--'
+class CodecRegistryError(exceptions.LookupError,
+ exceptions.SystemError):
+ pass
+
def search_function(encoding):
# Cache lookup
@@ -56,14 +60,14 @@ def search_function(encoding):
except AttributeError:
entry = ()
if len(entry) != 4:
- raise SystemError,\
- 'module "%s.%s" failed to register' % \
- (__name__,modname)
+ raise CodecRegistryError,\
+ 'module "%s" (%s) failed to register' % \
+ (mod.__name__, mod.__file__)
for obj in entry:
if not callable(obj):
- raise SystemError,\
- 'incompatible codecs in module "%s.%s"' % \
- (__name__,modname)
+ raise CodecRegistryError,\
+ 'incompatible codecs in module "%s" (%s)' % \
+ (mod.__name__, mod.__file__)
# Cache the codec registry entry
_cache[encoding] = entry