diff options
author | Fred Drake <fdrake@acm.org> | 2000-05-09 19:55:59 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-05-09 19:55:59 (GMT) |
commit | 766de83ab1b4752e9322b2b915d5aaf881b0ed9f (patch) | |
tree | a66091d0c68a65df1bc791a1bbb2f157fa7616b6 /Python | |
parent | c640b18d96b995c0bf61527317f7982b04bac21a (diff) | |
download | cpython-766de83ab1b4752e9322b2b915d5aaf881b0ed9f.zip cpython-766de83ab1b4752e9322b2b915d5aaf881b0ed9f.tar.gz cpython-766de83ab1b4752e9322b2b915d5aaf881b0ed9f.tar.bz2 |
M.-A. Lemburg <mal@lemburg.com>:
Moved some docs to the include file.
Added a NULL check to _PyCodec_Lookup() to make it
core dump safe.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/codecs.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 4df389a..5e01cca 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -55,14 +55,6 @@ int import_encodings() return 0; } -/* Register a new codec search function. - - As side effect, this tries to load the encodings package, if not - yet done, to make sure that it is always first in the list of - search functions. - - The search_function's refcount is incremented by this function. */ - int PyCodec_Register(PyObject *search_function) { if (!import_encodings_called) { @@ -117,7 +109,7 @@ PyObject *normalizestring(const char *string) characters. This makes encodings looked up through this mechanism effectively case-insensitive. - If no codec is found, a KeyError is set and NULL returned. + If no codec is found, a LookupError is set and NULL returned. As side effect, this tries to load the encodings package, if not yet done. This is part of the lazy load strategy for the encodings @@ -130,6 +122,10 @@ PyObject *_PyCodec_Lookup(const char *encoding) PyObject *result, *args = NULL, *v; int i, len; + if (encoding == NULL) { + PyErr_BadArgument(); + goto onError; + } if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) { PyErr_SetString(PyExc_SystemError, |