mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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.
This commit is contained in:
parent
c640b18d96
commit
766de83ab1
1 changed files with 5 additions and 9 deletions
|
@ -55,14 +55,6 @@ int import_encodings()
|
||||||
return 0;
|
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)
|
int PyCodec_Register(PyObject *search_function)
|
||||||
{
|
{
|
||||||
if (!import_encodings_called) {
|
if (!import_encodings_called) {
|
||||||
|
@ -117,7 +109,7 @@ PyObject *normalizestring(const char *string)
|
||||||
characters. This makes encodings looked up through this mechanism
|
characters. This makes encodings looked up through this mechanism
|
||||||
effectively case-insensitive.
|
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
|
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
|
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;
|
PyObject *result, *args = NULL, *v;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
|
if (encoding == NULL) {
|
||||||
|
PyErr_BadArgument();
|
||||||
|
goto onError;
|
||||||
|
}
|
||||||
if (_PyCodec_SearchCache == NULL ||
|
if (_PyCodec_SearchCache == NULL ||
|
||||||
_PyCodec_SearchPath == NULL) {
|
_PyCodec_SearchPath == NULL) {
|
||||||
PyErr_SetString(PyExc_SystemError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue