[Python-checkins] CVS: python/dist/src/Python codecs.c,2.1,2.2
Barry A. Warsaw
python-dev@python.org
Mon, 20 Mar 2000 11:36:51 -0500 (EST)
Update of /projects/cvsroot/python/dist/src/Python
In directory anthem:/home/bwarsaw/projects/python/Python
Modified Files:
codecs.c
Log Message:
On 17-Mar-2000, Marc-Andre Lemburg said:
Attached you find an update of the Unicode implementation.
The patch is against the current CVS version. I would appreciate
if someone with CVS checkin permissions could check the changes
in.
The patch contains all bugs and patches sent this week and also
fixes a leak in the codecs code and a bug in the free list code
for Unicode objects (which only shows up when compiling Python
with Py_DEBUG; thanks to MarkH for spotting this one).
Index: codecs.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/codecs.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** codecs.c 2000/03/10 22:57:27 2.1
--- codecs.c 2000/03/20 16:36:48 2.2
***************
*** 94,100 ****
PyObject *_PyCodec_Lookup(const char *encoding)
{
! PyObject *result, *args = NULL, *v;
int i, len;
if (!import_encodings_called)
import_encodings();
--- 94,105 ----
PyObject *_PyCodec_Lookup(const char *encoding)
{
! PyObject *result, *args = NULL, *v = NULL;
int i, len;
+ if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) {
+ PyErr_SetString(PyExc_SystemError,
+ "codec module not properly initialized");
+ goto onError;
+ }
if (!import_encodings_called)
import_encodings();
***************
*** 110,113 ****
--- 115,119 ----
if (result != NULL) {
Py_INCREF(result);
+ Py_DECREF(v);
return result;
}
***************
*** 122,125 ****
--- 128,132 ----
goto onError;
PyTuple_SET_ITEM(args,0,v);
+ v = NULL;
for (i = 0; i < len; i++) {
***************
*** 147,151 ****
/* XXX Perhaps we should cache misses too ? */
PyErr_SetString(PyExc_LookupError,
! "unkown encoding");
goto onError;
}
--- 154,158 ----
/* XXX Perhaps we should cache misses too ? */
PyErr_SetString(PyExc_LookupError,
! "unknown encoding");
goto onError;
}
***************
*** 157,160 ****
--- 164,168 ----
onError:
+ Py_XDECREF(v);
Py_XDECREF(args);
return NULL;
***************
*** 379,382 ****
--- 387,392 ----
{
Py_XDECREF(_PyCodec_SearchPath);
+ _PyCodec_SearchPath = NULL;
Py_XDECREF(_PyCodec_SearchCache);
+ _PyCodec_SearchCache = NULL;
}