Python Glossary Русский

all Python 3Exceptionsexception

encodings.CodecRegistryError

module exceptions

A codec registry error: a module in the encodings package returned an invalid or incompatible codec entry (a subclass of LookupError and SystemError).

Syntax

raise encodings.CodecRegistryError(...)

This is not about a wrong text encoding: an unknown encoding name gives a plain LookupError, and broken bytes give UnicodeDecodeError. CodecRegistryError means the codec machinery itself is broken — a module in the encodings package registered something unusable as CodecInfo. You will practically never meet it in course work, and since it inherits from both LookupError and SystemError, an except LookupError handler already catches it.

Examples

import encodings
print(issubclass(encodings.CodecRegistryError, Exception))   # → True
print(issubclass(encodings.CodecRegistryError, LookupError))   # → True
print(issubclass(encodings.CodecRegistryError, SystemError))   # → True
print(encodings.CodecRegistryError('bad search function'))   # → bad search function
print('abc'.encode('nosuchcodec'))   # → LookupError

See also

Open in the full glossarydocs.python.orgReport an inaccuracy