mirror of https://github.com/python/cpython
Fix PEP 293 related problems with --disable-unicode builds
reported by Michael Hudson in http://mail.python.org/pipermail/python-dev/2002-November/030299.html
This commit is contained in:
parent
cdd215789c
commit
bf73db835a
|
@ -138,8 +138,10 @@ PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(char *, int);
|
PyAPI_FUNC(void) PyErr_SyntaxLocation(char *, int);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_ProgramText(char *, int);
|
PyAPI_FUNC(PyObject *) PyErr_ProgramText(char *, int);
|
||||||
|
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
/* The following functions are used to create and modify unicode
|
/* The following functions are used to create and modify unicode
|
||||||
exceptions from C */
|
exceptions from C */
|
||||||
|
|
||||||
/* create a UnicodeDecodeError object */
|
/* create a UnicodeDecodeError object */
|
||||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
||||||
const char *, const char *, int, int, int, const char *);
|
const char *, const char *, int, int, int, const char *);
|
||||||
|
@ -198,6 +200,7 @@ PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
|
||||||
PyObject *, const char *);
|
PyObject *, const char *);
|
||||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
||||||
PyObject *, const char *);
|
PyObject *, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* These APIs aren't really part of the error implementation, but
|
/* These APIs aren't really part of the error implementation, but
|
||||||
|
|
|
@ -486,6 +486,7 @@ PyObject *PyCodec_StrictErrors(PyObject *exc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
PyObject *PyCodec_IgnoreErrors(PyObject *exc)
|
PyObject *PyCodec_IgnoreErrors(PyObject *exc)
|
||||||
{
|
{
|
||||||
int end;
|
int end;
|
||||||
|
@ -728,6 +729,7 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static PyObject *strict_errors(PyObject *self, PyObject *exc)
|
static PyObject *strict_errors(PyObject *self, PyObject *exc)
|
||||||
{
|
{
|
||||||
|
@ -735,6 +737,7 @@ static PyObject *strict_errors(PyObject *self, PyObject *exc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
static PyObject *ignore_errors(PyObject *self, PyObject *exc)
|
static PyObject *ignore_errors(PyObject *self, PyObject *exc)
|
||||||
{
|
{
|
||||||
return PyCodec_IgnoreErrors(exc);
|
return PyCodec_IgnoreErrors(exc);
|
||||||
|
@ -757,6 +760,7 @@ static PyObject *backslashreplace_errors(PyObject *self, PyObject *exc)
|
||||||
{
|
{
|
||||||
return PyCodec_BackslashReplaceErrors(exc);
|
return PyCodec_BackslashReplaceErrors(exc);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void _PyCodecRegistry_Init(void)
|
void _PyCodecRegistry_Init(void)
|
||||||
|
@ -774,6 +778,7 @@ void _PyCodecRegistry_Init(void)
|
||||||
METH_O
|
METH_O
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
{
|
{
|
||||||
"ignore",
|
"ignore",
|
||||||
{
|
{
|
||||||
|
@ -806,6 +811,7 @@ void _PyCodecRegistry_Init(void)
|
||||||
METH_O
|
METH_O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
if (_PyCodec_SearchPath == NULL)
|
if (_PyCodec_SearchPath == NULL)
|
||||||
_PyCodec_SearchPath = PyList_New(0);
|
_PyCodec_SearchPath = PyList_New(0);
|
||||||
|
|
|
@ -892,6 +892,7 @@ static PyMethodDef KeyError_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
static
|
static
|
||||||
int get_int(PyObject *exc, const char *name, int *value)
|
int get_int(PyObject *exc, const char *name, int *value)
|
||||||
{
|
{
|
||||||
|
@ -1469,6 +1470,7 @@ PyObject * PyUnicodeTranslateError_Create(
|
||||||
return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#iis",
|
return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#iis",
|
||||||
object, length, start, end, reason);
|
object, length, start, end, reason);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1496,11 +1498,13 @@ PyDoc_STRVAR(ValueError__doc__,
|
||||||
|
|
||||||
PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error.");
|
PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error.");
|
||||||
|
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
PyDoc_STRVAR(UnicodeEncodeError__doc__, "Unicode encoding error.");
|
PyDoc_STRVAR(UnicodeEncodeError__doc__, "Unicode encoding error.");
|
||||||
|
|
||||||
PyDoc_STRVAR(UnicodeDecodeError__doc__, "Unicode decoding error.");
|
PyDoc_STRVAR(UnicodeDecodeError__doc__, "Unicode decoding error.");
|
||||||
|
|
||||||
PyDoc_STRVAR(UnicodeTranslateError__doc__, "Unicode translation error.");
|
PyDoc_STRVAR(UnicodeTranslateError__doc__, "Unicode translation error.");
|
||||||
|
#endif
|
||||||
|
|
||||||
PyDoc_STRVAR(SystemError__doc__,
|
PyDoc_STRVAR(SystemError__doc__,
|
||||||
"Internal error in the Python interpreter.\n\
|
"Internal error in the Python interpreter.\n\
|
||||||
|
@ -1675,12 +1679,14 @@ static struct {
|
||||||
FloatingPointError__doc__},
|
FloatingPointError__doc__},
|
||||||
{"ValueError", &PyExc_ValueError, 0, ValueError__doc__},
|
{"ValueError", &PyExc_ValueError, 0, ValueError__doc__},
|
||||||
{"UnicodeError", &PyExc_UnicodeError, &PyExc_ValueError, UnicodeError__doc__},
|
{"UnicodeError", &PyExc_UnicodeError, &PyExc_ValueError, UnicodeError__doc__},
|
||||||
|
#ifdef Py_USING_UNICODE
|
||||||
{"UnicodeEncodeError", &PyExc_UnicodeEncodeError, &PyExc_UnicodeError,
|
{"UnicodeEncodeError", &PyExc_UnicodeEncodeError, &PyExc_UnicodeError,
|
||||||
UnicodeEncodeError__doc__, UnicodeEncodeError_methods},
|
UnicodeEncodeError__doc__, UnicodeEncodeError_methods},
|
||||||
{"UnicodeDecodeError", &PyExc_UnicodeDecodeError, &PyExc_UnicodeError,
|
{"UnicodeDecodeError", &PyExc_UnicodeDecodeError, &PyExc_UnicodeError,
|
||||||
UnicodeDecodeError__doc__, UnicodeDecodeError_methods},
|
UnicodeDecodeError__doc__, UnicodeDecodeError_methods},
|
||||||
{"UnicodeTranslateError", &PyExc_UnicodeTranslateError, &PyExc_UnicodeError,
|
{"UnicodeTranslateError", &PyExc_UnicodeTranslateError, &PyExc_UnicodeError,
|
||||||
UnicodeTranslateError__doc__, UnicodeTranslateError_methods},
|
UnicodeTranslateError__doc__, UnicodeTranslateError_methods},
|
||||||
|
#endif
|
||||||
{"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__},
|
{"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__},
|
||||||
{"SystemError", &PyExc_SystemError, 0, SystemError__doc__},
|
{"SystemError", &PyExc_SystemError, 0, SystemError__doc__},
|
||||||
{"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__},
|
{"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__},
|
||||||
|
|
Loading…
Reference in New Issue