[I18n-sig] More grief on Windows
M.-A. Lemburg
mal@lemburg.com
Fri, 24 Mar 2000 00:21:31 +0100
"M.-A. Lemburg" wrote:
>
> Andy Robinson wrote:
> >
> > I've built the Unicode-aware Python on Windows, with a proper encodings
> > library.
> > The moment I try to look up a codec, python crashes...
> >
> > C:\users>python
> > Python 1.5.2+ (#0, Mar 23 2000, 15:31:41) [MSC 32 bit (Intel)] on win32
> > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > >>> unicode('hello','ascii')
> > !!!! Application Error at this point
>
> I can reproduce this on Linux too... I'll look into this and
> send a patch.
Here it is:
--- CVS-Python/Python/codecs.c Fri Mar 24 00:02:04 2000
+++ Python+Unicode/Python/codecs.c Fri Mar 24 00:01:49 2000
@@ -91,11 +91,11 @@ PyObject *lowercasestring(const char *st
If no codec is found, a KeyError is set and NULL returned. */
PyObject *_PyCodec_Lookup(const char *encoding)
{
- PyObject *result, *args = NULL, *v = NULL;
+ PyObject *result, *args = NULL, *v;
int i, len;
if (_PyCodec_SearchCache == NULL || _PyCodec_SearchPath == NULL) {
PyErr_SetString(PyExc_SystemError,
"codec module not properly initialized");
@@ -117,27 +117,26 @@ PyObject *_PyCodec_Lookup(const char *en
Py_DECREF(v);
return result;
}
/* Next, scan the search functions in order of registration */
- len = PyList_Size(_PyCodec_SearchPath);
- if (len < 0)
- goto onError;
-
args = PyTuple_New(1);
if (args == NULL)
goto onError;
PyTuple_SET_ITEM(args,0,v);
- v = NULL;
+
+ len = PyList_Size(_PyCodec_SearchPath);
+ if (len < 0)
+ goto onError;
for (i = 0; i < len; i++) {
PyObject *func;
func = PyList_GetItem(_PyCodec_SearchPath, i);
if (func == NULL)
goto onError;
- result = PyEval_CallObject(func,args);
+ result = PyEval_CallObject(func, args);
if (result == NULL)
goto onError;
if (result == Py_None) {
Py_DECREF(result);
continue;
@@ -161,11 +160,10 @@ PyObject *_PyCodec_Lookup(const char *en
PyDict_SetItem(_PyCodec_SearchCache, v, result);
Py_DECREF(args);
return result;
onError:
- Py_XDECREF(v);
Py_XDECREF(args);
return NULL;
}
static
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/