Get rid of all #ifdef Py_USING_UNICODE (it is always present now).
(With the help of unifdef from freshmeat.)
This commit is contained in:
parent
938ef57e26
commit
8d30cc0144
|
@ -51,9 +51,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
|
||||||
#endif /* HAVE_LONG_LONG */
|
#endif /* HAVE_LONG_LONG */
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
|
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
|
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
|
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
|
||||||
v must not be NULL, and must be a normalized long.
|
v must not be NULL, and must be a normalized long.
|
||||||
|
|
|
@ -374,9 +374,7 @@ PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
|
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *);
|
PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
|
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *);
|
PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *);
|
||||||
#endif
|
|
||||||
PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
|
PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
|
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
|
||||||
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
|
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
|
||||||
|
|
|
@ -26,7 +26,6 @@ typedef struct {
|
||||||
PyObject *print_file_and_line;
|
PyObject *print_file_and_line;
|
||||||
} PySyntaxErrorObject;
|
} PySyntaxErrorObject;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
PyObject *dict;
|
PyObject *dict;
|
||||||
|
@ -38,7 +37,6 @@ typedef struct {
|
||||||
PyObject *end;
|
PyObject *end;
|
||||||
PyObject *reason;
|
PyObject *reason;
|
||||||
} PyUnicodeErrorObject;
|
} PyUnicodeErrorObject;
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
@ -235,7 +233,6 @@ PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
|
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
|
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const 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 */
|
||||||
|
|
||||||
|
@ -297,7 +294,6 @@ 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
|
||||||
|
|
|
@ -58,13 +58,6 @@ Copyright (c) Corporation for National Research Initiatives.
|
||||||
|
|
||||||
/* --- Internal Unicode Format -------------------------------------------- */
|
/* --- Internal Unicode Format -------------------------------------------- */
|
||||||
|
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
|
|
||||||
#define PyUnicode_Check(op) 0
|
|
||||||
#define PyUnicode_CheckExact(op) 0
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is
|
/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is
|
||||||
properly set, but the default rules below doesn't set it. I'll
|
properly set, but the default rules below doesn't set it. I'll
|
||||||
sort this out some other day -- fredrik@pythonware.com */
|
sort this out some other day -- fredrik@pythonware.com */
|
||||||
|
@ -1262,5 +1255,4 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* Py_USING_UNICODE */
|
|
||||||
#endif /* !Py_UNICODEOBJECT_H */
|
#endif /* !Py_UNICODEOBJECT_H */
|
||||||
|
|
|
@ -93,15 +93,8 @@ codec_encode(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
|
if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (encoding == NULL)
|
if (encoding == NULL)
|
||||||
encoding = PyUnicode_GetDefaultEncoding();
|
encoding = PyUnicode_GetDefaultEncoding();
|
||||||
#else
|
|
||||||
if (encoding == NULL) {
|
|
||||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Encode via the codec registry */
|
/* Encode via the codec registry */
|
||||||
return PyCodec_Encode(v, encoding, errors);
|
return PyCodec_Encode(v, encoding, errors);
|
||||||
|
@ -127,15 +120,8 @@ codec_decode(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
|
if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (encoding == NULL)
|
if (encoding == NULL)
|
||||||
encoding = PyUnicode_GetDefaultEncoding();
|
encoding = PyUnicode_GetDefaultEncoding();
|
||||||
#else
|
|
||||||
if (encoding == NULL) {
|
|
||||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Decode via the codec registry */
|
/* Decode via the codec registry */
|
||||||
return PyCodec_Decode(v, encoding, errors);
|
return PyCodec_Decode(v, encoding, errors);
|
||||||
|
@ -198,7 +184,6 @@ escape_encode(PyObject *self,
|
||||||
return codec_tuple(str, PyString_Size(str));
|
return codec_tuple(str, PyString_Size(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* --- Decoder ------------------------------------------------------------ */
|
/* --- Decoder ------------------------------------------------------------ */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -833,7 +818,6 @@ mbcs_encode(PyObject *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
#endif /* Py_USING_UNICODE */
|
|
||||||
|
|
||||||
/* --- Error handler registry --------------------------------------------- */
|
/* --- Error handler registry --------------------------------------------- */
|
||||||
|
|
||||||
|
@ -888,7 +872,6 @@ static PyMethodDef _codecs_functions[] = {
|
||||||
decode__doc__},
|
decode__doc__},
|
||||||
{"escape_encode", escape_encode, METH_VARARGS},
|
{"escape_encode", escape_encode, METH_VARARGS},
|
||||||
{"escape_decode", escape_decode, METH_VARARGS},
|
{"escape_decode", escape_decode, METH_VARARGS},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"utf_8_encode", utf_8_encode, METH_VARARGS},
|
{"utf_8_encode", utf_8_encode, METH_VARARGS},
|
||||||
{"utf_8_decode", utf_8_decode, METH_VARARGS},
|
{"utf_8_decode", utf_8_decode, METH_VARARGS},
|
||||||
{"utf_7_encode", utf_7_encode, METH_VARARGS},
|
{"utf_7_encode", utf_7_encode, METH_VARARGS},
|
||||||
|
@ -919,7 +902,6 @@ static PyMethodDef _codecs_functions[] = {
|
||||||
{"mbcs_encode", mbcs_encode, METH_VARARGS},
|
{"mbcs_encode", mbcs_encode, METH_VARARGS},
|
||||||
{"mbcs_decode", mbcs_decode, METH_VARARGS},
|
{"mbcs_decode", mbcs_decode, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
#endif /* Py_USING_UNICODE */
|
|
||||||
{"register_error", register_error, METH_VARARGS,
|
{"register_error", register_error, METH_VARARGS,
|
||||||
register_error__doc__},
|
register_error__doc__},
|
||||||
{"lookup_error", lookup_error, METH_VARARGS,
|
{"lookup_error", lookup_error, METH_VARARGS,
|
||||||
|
|
|
@ -93,27 +93,6 @@ do { memory -= size; printf("%8d - %s\n", memory, comment); } while (0)
|
||||||
#define LOCAL(type) static type
|
#define LOCAL(type) static type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* compatibility macros */
|
|
||||||
#if (PY_VERSION_HEX < 0x02050000)
|
|
||||||
typedef int Py_ssize_t;
|
|
||||||
#define lenfunc inquiry
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (PY_VERSION_HEX < 0x02040000)
|
|
||||||
#define PyDict_CheckExact PyDict_Check
|
|
||||||
#if (PY_VERSION_HEX < 0x02020000)
|
|
||||||
#define PyList_CheckExact PyList_Check
|
|
||||||
#define PyString_CheckExact PyString_Check
|
|
||||||
#if (PY_VERSION_HEX >= 0x01060000)
|
|
||||||
#define Py_USING_UNICODE /* always enabled for 2.0 and 2.1 */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(Py_RETURN_NONE)
|
|
||||||
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* macros used to store 'join' flags in string object pointers. note
|
/* macros used to store 'join' flags in string object pointers. note
|
||||||
that all use of text and tail as object pointers must be wrapped in
|
that all use of text and tail as object pointers must be wrapped in
|
||||||
JOIN_OBJ. see comments in the ElementObject definition for more
|
JOIN_OBJ. see comments in the ElementObject definition for more
|
||||||
|
@ -724,7 +703,6 @@ checkpath(PyObject* tag)
|
||||||
|
|
||||||
#define PATHCHAR(ch) (ch == '/' || ch == '*' || ch == '[' || ch == '@')
|
#define PATHCHAR(ch) (ch == '/' || ch == '*' || ch == '[' || ch == '@')
|
||||||
|
|
||||||
#if defined(Py_USING_UNICODE)
|
|
||||||
if (PyUnicode_Check(tag)) {
|
if (PyUnicode_Check(tag)) {
|
||||||
Py_UNICODE *p = PyUnicode_AS_UNICODE(tag);
|
Py_UNICODE *p = PyUnicode_AS_UNICODE(tag);
|
||||||
for (i = 0; i < PyUnicode_GET_SIZE(tag); i++) {
|
for (i = 0; i < PyUnicode_GET_SIZE(tag); i++) {
|
||||||
|
@ -737,7 +715,6 @@ checkpath(PyObject* tag)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (PyString_Check(tag)) {
|
if (PyString_Check(tag)) {
|
||||||
char *p = PyString_AS_STRING(tag);
|
char *p = PyString_AS_STRING(tag);
|
||||||
for (i = 0; i < PyString_GET_SIZE(tag); i++) {
|
for (i = 0; i < PyString_GET_SIZE(tag); i++) {
|
||||||
|
@ -1860,7 +1837,6 @@ static PyTypeObject XMLParser_Type;
|
||||||
|
|
||||||
/* helpers */
|
/* helpers */
|
||||||
|
|
||||||
#if defined(Py_USING_UNICODE)
|
|
||||||
LOCAL(int)
|
LOCAL(int)
|
||||||
checkstring(const char* string, int size)
|
checkstring(const char* string, int size)
|
||||||
{
|
{
|
||||||
|
@ -1873,7 +1849,6 @@ checkstring(const char* string, int size)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
LOCAL(PyObject*)
|
LOCAL(PyObject*)
|
||||||
makestring(const char* string, int size)
|
makestring(const char* string, int size)
|
||||||
|
@ -1881,10 +1856,8 @@ makestring(const char* string, int size)
|
||||||
/* convert a UTF-8 string to either a 7-bit ascii string or a
|
/* convert a UTF-8 string to either a 7-bit ascii string or a
|
||||||
Unicode string */
|
Unicode string */
|
||||||
|
|
||||||
#if defined(Py_USING_UNICODE)
|
|
||||||
if (checkstring(string, size))
|
if (checkstring(string, size))
|
||||||
return PyUnicode_DecodeUTF8(string, size, "strict");
|
return PyUnicode_DecodeUTF8(string, size, "strict");
|
||||||
#endif
|
|
||||||
|
|
||||||
return PyString_FromStringAndSize(string, size);
|
return PyString_FromStringAndSize(string, size);
|
||||||
}
|
}
|
||||||
|
@ -1934,7 +1907,6 @@ makeuniversal(XMLParserObject* self, const char* string)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode universal name */
|
/* decode universal name */
|
||||||
#if defined(Py_USING_UNICODE)
|
|
||||||
/* inline makestring, to avoid duplicating the source string if
|
/* inline makestring, to avoid duplicating the source string if
|
||||||
it's not an utf-8 string */
|
it's not an utf-8 string */
|
||||||
p = PyString_AS_STRING(tag);
|
p = PyString_AS_STRING(tag);
|
||||||
|
@ -1946,7 +1918,6 @@ makeuniversal(XMLParserObject* self, const char* string)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
|
||||||
value = tag; /* use tag as is */
|
value = tag; /* use tag as is */
|
||||||
|
|
||||||
/* add to names dictionary */
|
/* add to names dictionary */
|
||||||
|
@ -2163,7 +2134,6 @@ expat_pi_handler(XMLParserObject* self, const XML_Char* target_in,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Py_USING_UNICODE)
|
|
||||||
static int
|
static int
|
||||||
expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
|
expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
|
||||||
XML_Encoding *info)
|
XML_Encoding *info)
|
||||||
|
@ -2200,7 +2170,6 @@ expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
|
||||||
|
|
||||||
return XML_STATUS_OK;
|
return XML_STATUS_OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* constructor and destructor */
|
/* constructor and destructor */
|
||||||
|
@ -2306,12 +2275,10 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
|
||||||
self->parser,
|
self->parser,
|
||||||
(XML_ProcessingInstructionHandler) expat_pi_handler
|
(XML_ProcessingInstructionHandler) expat_pi_handler
|
||||||
);
|
);
|
||||||
#if defined(Py_USING_UNICODE)
|
|
||||||
EXPAT(SetUnknownEncodingHandler)(
|
EXPAT(SetUnknownEncodingHandler)(
|
||||||
self->parser,
|
self->parser,
|
||||||
(XML_UnknownEncodingHandler) expat_unknown_encoding_handler, NULL
|
(XML_UnknownEncodingHandler) expat_unknown_encoding_handler, NULL
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
ALLOC(sizeof(XMLParserObject), "create expatparser");
|
ALLOC(sizeof(XMLParserObject), "create expatparser");
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ PyDoc_STRVAR(strcoll__doc__,
|
||||||
static PyObject*
|
static PyObject*
|
||||||
PyLocale_strcoll(PyObject* self, PyObject* args)
|
PyLocale_strcoll(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
#if !defined(HAVE_WCSCOLL) || !defined(Py_USING_UNICODE)
|
#if !defined(HAVE_WCSCOLL)
|
||||||
char *s1,*s2;
|
char *s1,*s2;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ss:strcoll", &s1, &s2))
|
if (!PyArg_ParseTuple(args, "ss:strcoll", &s1, &s2))
|
||||||
|
|
|
@ -58,12 +58,8 @@ static char copyright[] =
|
||||||
/* defining this one enables tracing */
|
/* defining this one enables tracing */
|
||||||
#undef VERBOSE
|
#undef VERBOSE
|
||||||
|
|
||||||
#if PY_VERSION_HEX >= 0x01060000
|
|
||||||
#if PY_VERSION_HEX < 0x02020000 || defined(Py_USING_UNICODE)
|
|
||||||
/* defining this enables unicode support (default under 1.6a1 and later) */
|
/* defining this enables unicode support (default under 1.6a1 and later) */
|
||||||
#define HAVE_UNICODE
|
#define HAVE_UNICODE
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* optional features */
|
/* optional features */
|
||||||
|
|
|
@ -456,7 +456,6 @@ test_k_code(PyObject *self)
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
|
|
||||||
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
|
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
|
||||||
of an error.
|
of an error.
|
||||||
|
@ -518,7 +517,6 @@ codec_incrementaldecoder(PyObject *self, PyObject *args)
|
||||||
return PyCodec_IncrementalDecoder(encoding, errors);
|
return PyCodec_IncrementalDecoder(encoding, errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Simple test of _PyLong_NumBits and _PyLong_Sign. */
|
/* Simple test of _PyLong_NumBits and _PyLong_Sign. */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -863,9 +861,7 @@ static PyMethodDef TestMethods[] = {
|
||||||
{"codec_incrementaldecoder",
|
{"codec_incrementaldecoder",
|
||||||
(PyCFunction)codec_incrementaldecoder, METH_VARARGS},
|
(PyCFunction)codec_incrementaldecoder, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"test_u_code", (PyCFunction)test_u_code, METH_NOARGS},
|
{"test_u_code", (PyCFunction)test_u_code, METH_NOARGS},
|
||||||
#endif
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
{"_test_thread_state", test_thread_state, METH_VARARGS},
|
{"_test_thread_state", test_thread_state, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -337,7 +337,6 @@ AsString(PyObject *value, PyObject *tmp)
|
||||||
{
|
{
|
||||||
if (PyString_Check(value))
|
if (PyString_Check(value))
|
||||||
return PyString_AsString(value);
|
return PyString_AsString(value);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(value)) {
|
else if (PyUnicode_Check(value)) {
|
||||||
PyObject *v = PyUnicode_AsUTF8String(value);
|
PyObject *v = PyUnicode_AsUTF8String(value);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
|
@ -349,7 +348,6 @@ AsString(PyObject *value, PyObject *tmp)
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return PyString_AsString(v);
|
return PyString_AsString(v);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else {
|
else {
|
||||||
PyObject *v = PyObject_Str(value);
|
PyObject *v = PyObject_Str(value);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
|
@ -775,7 +773,6 @@ PyTclObject_string(PyTclObject *self, void *ignored)
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (s[i] & 0x80)
|
if (s[i] & 0x80)
|
||||||
break;
|
break;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (i == len)
|
if (i == len)
|
||||||
/* It is an ASCII string. */
|
/* It is an ASCII string. */
|
||||||
self->string = PyString_FromStringAndSize(s, len);
|
self->string = PyString_FromStringAndSize(s, len);
|
||||||
|
@ -786,9 +783,6 @@ PyTclObject_string(PyTclObject *self, void *ignored)
|
||||||
self->string = PyString_FromStringAndSize(s, len);
|
self->string = PyString_FromStringAndSize(s, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
self->string = PyString_FromStringAndSize(s, len);
|
|
||||||
#endif
|
|
||||||
if (!self->string)
|
if (!self->string)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -796,7 +790,6 @@ PyTclObject_string(PyTclObject *self, void *ignored)
|
||||||
return self->string;
|
return self->string;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyDoc_STRVAR(PyTclObject_unicode__doc__, "convert argument to unicode");
|
PyDoc_STRVAR(PyTclObject_unicode__doc__, "convert argument to unicode");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -812,7 +805,6 @@ PyTclObject_unicode(PyTclObject *self, void *ignored)
|
||||||
s = Tcl_GetStringFromObj(self->value, &len);
|
s = Tcl_GetStringFromObj(self->value, &len);
|
||||||
return PyUnicode_DecodeUTF8(s, len, "strict");
|
return PyUnicode_DecodeUTF8(s, len, "strict");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
PyTclObject_repr(PyTclObject *self)
|
PyTclObject_repr(PyTclObject *self)
|
||||||
|
@ -851,10 +843,8 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyMethodDef PyTclObject_methods[] = {
|
static PyMethodDef PyTclObject_methods[] = {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS,
|
{"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS,
|
||||||
PyTclObject_unicode__doc__},
|
PyTclObject_unicode__doc__},
|
||||||
#endif
|
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -929,7 +919,6 @@ AsObj(PyObject *value)
|
||||||
ckfree(FREECAST argv);
|
ckfree(FREECAST argv);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(value)) {
|
else if (PyUnicode_Check(value)) {
|
||||||
Py_UNICODE *inbuf = PyUnicode_AS_UNICODE(value);
|
Py_UNICODE *inbuf = PyUnicode_AS_UNICODE(value);
|
||||||
Py_ssize_t size = PyUnicode_GET_SIZE(value);
|
Py_ssize_t size = PyUnicode_GET_SIZE(value);
|
||||||
|
@ -962,7 +951,6 @@ AsObj(PyObject *value)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if(PyTclObject_Check(value)) {
|
else if(PyTclObject_Check(value)) {
|
||||||
Tcl_Obj *v = ((PyTclObject*)value)->value;
|
Tcl_Obj *v = ((PyTclObject*)value)->value;
|
||||||
Tcl_IncrRefCount(v);
|
Tcl_IncrRefCount(v);
|
||||||
|
@ -987,7 +975,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||||
if (value->typePtr == NULL) {
|
if (value->typePtr == NULL) {
|
||||||
/* If the result contains any bytes with the top bit set,
|
/* If the result contains any bytes with the top bit set,
|
||||||
it's UTF-8 and we should decode it to Unicode */
|
it's UTF-8 and we should decode it to Unicode */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
int i;
|
int i;
|
||||||
char *s = value->bytes;
|
char *s = value->bytes;
|
||||||
int len = value->length;
|
int len = value->length;
|
||||||
|
@ -1006,9 +993,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||||
result = PyString_FromStringAndSize(s, len);
|
result = PyString_FromStringAndSize(s, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
result = PyString_FromStringAndSize(value->bytes, value->length);
|
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,7 +1050,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value->typePtr == app->StringType) {
|
if (value->typePtr == app->StringType) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
#if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX==3
|
#if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX==3
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
int size;
|
int size;
|
||||||
|
@ -1085,12 +1068,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||||
#else
|
#else
|
||||||
return PyUnicode_FromUnicode(Tcl_GetUnicode(value),
|
return PyUnicode_FromUnicode(Tcl_GetUnicode(value),
|
||||||
Tcl_GetCharLength(value));
|
Tcl_GetCharLength(value));
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
int size;
|
|
||||||
char *c;
|
|
||||||
c = Tcl_GetStringFromObj(value, &size);
|
|
||||||
return PyString_FromStringAndSize(c, size);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,7 +1171,6 @@ Tkapp_CallResult(TkappObject *self)
|
||||||
|
|
||||||
/* If the result contains any bytes with the top bit set,
|
/* If the result contains any bytes with the top bit set,
|
||||||
it's UTF-8 and we should decode it to Unicode */
|
it's UTF-8 and we should decode it to Unicode */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
while (*p != '\0') {
|
while (*p != '\0') {
|
||||||
if (*p & 0x80)
|
if (*p & 0x80)
|
||||||
break;
|
break;
|
||||||
|
@ -1212,10 +1188,6 @@ Tkapp_CallResult(TkappObject *self)
|
||||||
res = PyString_FromStringAndSize(s, (int)(p-s));
|
res = PyString_FromStringAndSize(s, (int)(p-s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
p = strchr(p, '\0');
|
|
||||||
res = PyString_FromStringAndSize(s, (int)(p-s));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,6 @@ BB_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
u_getitem(arrayobject *ap, Py_ssize_t i)
|
u_getitem(arrayobject *ap, Py_ssize_t i)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +193,6 @@ u_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
|
||||||
((Py_UNICODE *)ap->ob_item)[i] = p[0];
|
((Py_UNICODE *)ap->ob_item)[i] = p[0];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
h_getitem(arrayobject *ap, Py_ssize_t i)
|
h_getitem(arrayobject *ap, Py_ssize_t i)
|
||||||
|
@ -394,9 +392,7 @@ static struct arraydescr descriptors[] = {
|
||||||
{'c', sizeof(char), c_getitem, c_setitem},
|
{'c', sizeof(char), c_getitem, c_setitem},
|
||||||
{'b', sizeof(char), b_getitem, b_setitem},
|
{'b', sizeof(char), b_getitem, b_setitem},
|
||||||
{'B', sizeof(char), BB_getitem, BB_setitem},
|
{'B', sizeof(char), BB_getitem, BB_setitem},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{'u', sizeof(Py_UNICODE), u_getitem, u_setitem},
|
{'u', sizeof(Py_UNICODE), u_getitem, u_setitem},
|
||||||
#endif
|
|
||||||
{'h', sizeof(short), h_getitem, h_setitem},
|
{'h', sizeof(short), h_getitem, h_setitem},
|
||||||
{'H', sizeof(short), HH_getitem, HH_setitem},
|
{'H', sizeof(short), HH_getitem, HH_setitem},
|
||||||
{'i', sizeof(int), i_getitem, i_setitem},
|
{'i', sizeof(int), i_getitem, i_setitem},
|
||||||
|
@ -1430,7 +1426,6 @@ representation.");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
array_fromunicode(arrayobject *self, PyObject *args)
|
array_fromunicode(arrayobject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
@ -1491,7 +1486,6 @@ a type 'u' array; otherwise a ValueError is raised. Use\n\
|
||||||
array.tostring().decode() to obtain a unicode string from\n\
|
array.tostring().decode() to obtain a unicode string from\n\
|
||||||
an array of some other type.");
|
an array of some other type.");
|
||||||
|
|
||||||
#endif /* Py_USING_UNICODE */
|
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1536,10 +1530,8 @@ PyMethodDef array_methods[] = {
|
||||||
fromlist_doc},
|
fromlist_doc},
|
||||||
{"fromstring", (PyCFunction)array_fromstring, METH_VARARGS,
|
{"fromstring", (PyCFunction)array_fromstring, METH_VARARGS,
|
||||||
fromstring_doc},
|
fromstring_doc},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"fromunicode", (PyCFunction)array_fromunicode, METH_VARARGS,
|
{"fromunicode", (PyCFunction)array_fromunicode, METH_VARARGS,
|
||||||
fromunicode_doc},
|
fromunicode_doc},
|
||||||
#endif
|
|
||||||
{"index", (PyCFunction)array_index, METH_O,
|
{"index", (PyCFunction)array_index, METH_O,
|
||||||
index_doc},
|
index_doc},
|
||||||
{"insert", (PyCFunction)array_insert, METH_VARARGS,
|
{"insert", (PyCFunction)array_insert, METH_VARARGS,
|
||||||
|
@ -1562,10 +1554,8 @@ PyMethodDef array_methods[] = {
|
||||||
tolist_doc},
|
tolist_doc},
|
||||||
{"tostring", (PyCFunction)array_tostring, METH_NOARGS,
|
{"tostring", (PyCFunction)array_tostring, METH_NOARGS,
|
||||||
tostring_doc},
|
tostring_doc},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"tounicode", (PyCFunction)array_tounicode, METH_NOARGS,
|
{"tounicode", (PyCFunction)array_tounicode, METH_NOARGS,
|
||||||
tounicode_doc},
|
tounicode_doc},
|
||||||
#endif
|
|
||||||
{"write", (PyCFunction)array_tofile, METH_O,
|
{"write", (PyCFunction)array_tofile, METH_O,
|
||||||
tofile_doc},
|
tofile_doc},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
|
@ -1587,10 +1577,8 @@ array_repr(arrayobject *a)
|
||||||
|
|
||||||
if (typecode == 'c')
|
if (typecode == 'c')
|
||||||
v = array_tostring(a, NULL);
|
v = array_tostring(a, NULL);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (typecode == 'u')
|
else if (typecode == 'u')
|
||||||
v = array_tounicode(a, NULL);
|
v = array_tounicode(a, NULL);
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
v = array_tolist(a, NULL);
|
v = array_tolist(a, NULL);
|
||||||
t = PyObject_Repr(v);
|
t = PyObject_Repr(v);
|
||||||
|
@ -1899,7 +1887,6 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
} else if (initial != NULL && PyUnicode_Check(initial)) {
|
} else if (initial != NULL && PyUnicode_Check(initial)) {
|
||||||
Py_ssize_t n = PyUnicode_GET_DATA_SIZE(initial);
|
Py_ssize_t n = PyUnicode_GET_DATA_SIZE(initial);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
|
@ -1916,7 +1903,6 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
memcpy(item, PyUnicode_AS_DATA(initial), n);
|
memcpy(item, PyUnicode_AS_DATA(initial), n);
|
||||||
self->allocated = self->ob_size;
|
self->allocated = self->ob_size;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (it != NULL) {
|
if (it != NULL) {
|
||||||
if (array_iter_extend((arrayobject *)a, it) == -1) {
|
if (array_iter_extend((arrayobject *)a, it) == -1) {
|
||||||
|
|
|
@ -1256,7 +1256,6 @@ save_string(Picklerobject *self, PyObject *args, int doput)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* A copy of PyUnicode_EncodeRawUnicodeEscape() that also translates
|
/* A copy of PyUnicode_EncodeRawUnicodeEscape() that also translates
|
||||||
backslash and newline characters to \uXXXX escapes. */
|
backslash and newline characters to \uXXXX escapes. */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1373,7 +1372,6 @@ save_unicode(Picklerobject *self, PyObject *args, int doput)
|
||||||
Py_XDECREF(repr);
|
Py_XDECREF(repr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* A helper for save_tuple. Push the len elements in tuple t on the stack. */
|
/* A helper for save_tuple. Push the len elements in tuple t on the stack. */
|
||||||
static int
|
static int
|
||||||
|
@ -2225,13 +2223,11 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'u':
|
case 'u':
|
||||||
if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
|
if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
|
||||||
res = save_unicode(self, args, 0);
|
res = save_unicode(self, args, 0);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->ob_refcnt > 1) {
|
if (args->ob_refcnt > 1) {
|
||||||
|
@ -2255,14 +2251,12 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'u':
|
case 'u':
|
||||||
if (type == &PyUnicode_Type) {
|
if (type == &PyUnicode_Type) {
|
||||||
res = save_unicode(self, args, 1);
|
res = save_unicode(self, args, 1);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
if (type == &PyTuple_Type) {
|
if (type == &PyTuple_Type) {
|
||||||
|
@ -3326,7 +3320,6 @@ load_short_binstring(Unpicklerobject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static int
|
static int
|
||||||
load_unicode(Unpicklerobject *self)
|
load_unicode(Unpicklerobject *self)
|
||||||
{
|
{
|
||||||
|
@ -3346,10 +3339,8 @@ load_unicode(Unpicklerobject *self)
|
||||||
finally:
|
finally:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static int
|
static int
|
||||||
load_binunicode(Unpicklerobject *self)
|
load_binunicode(Unpicklerobject *self)
|
||||||
{
|
{
|
||||||
|
@ -3370,7 +3361,6 @@ load_binunicode(Unpicklerobject *self)
|
||||||
PDATA_PUSH(self->stack, unicode, -1);
|
PDATA_PUSH(self->stack, unicode, -1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -4347,7 +4337,6 @@ load(Unpicklerobject *self)
|
||||||
break;
|
break;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case UNICODE:
|
case UNICODE:
|
||||||
if (load_unicode(self) < 0)
|
if (load_unicode(self) < 0)
|
||||||
break;
|
break;
|
||||||
|
@ -4357,7 +4346,6 @@ load(Unpicklerobject *self)
|
||||||
if (load_binunicode(self) < 0)
|
if (load_binunicode(self) < 0)
|
||||||
break;
|
break;
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
|
||||||
case EMPTY_TUPLE:
|
case EMPTY_TUPLE:
|
||||||
if (load_counted_tuple(self, 0) < 0)
|
if (load_counted_tuple(self, 0) < 0)
|
||||||
|
@ -4737,7 +4725,6 @@ noload(Unpicklerobject *self)
|
||||||
break;
|
break;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case UNICODE:
|
case UNICODE:
|
||||||
if (load_unicode(self) < 0)
|
if (load_unicode(self) < 0)
|
||||||
break;
|
break;
|
||||||
|
@ -4747,7 +4734,6 @@ noload(Unpicklerobject *self)
|
||||||
if (load_binunicode(self) < 0)
|
if (load_binunicode(self) < 0)
|
||||||
break;
|
break;
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
|
||||||
case EMPTY_TUPLE:
|
case EMPTY_TUPLE:
|
||||||
if (load_counted_tuple(self, 0) < 0)
|
if (load_counted_tuple(self, 0) < 0)
|
||||||
|
|
|
@ -44,10 +44,6 @@ standardized by the C Standard and the POSIX standard (a thinly\n\
|
||||||
disguised Unix interface). Refer to the library manual and\n\
|
disguised Unix interface). Refer to the library manual and\n\
|
||||||
corresponding Unix manual entries for more information on calls.");
|
corresponding Unix manual entries for more information on calls.");
|
||||||
|
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
/* This is used in signatures of functions. */
|
|
||||||
#define Py_UNICODE void
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PYOS_OS2)
|
#if defined(PYOS_OS2)
|
||||||
#define INCL_DOS
|
#define INCL_DOS
|
||||||
|
@ -1895,7 +1891,6 @@ posix_getcwd(PyObject *self, PyObject *noargs)
|
||||||
return PyString_FromString(buf);
|
return PyString_FromString(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyDoc_STRVAR(posix_getcwdu__doc__,
|
PyDoc_STRVAR(posix_getcwdu__doc__,
|
||||||
"getcwdu() -> path\n\n\
|
"getcwdu() -> path\n\n\
|
||||||
Return a unicode string representing the current working directory.");
|
Return a unicode string representing the current working directory.");
|
||||||
|
@ -1949,7 +1944,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs)
|
||||||
return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"strict");
|
return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"strict");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LINK
|
#ifdef HAVE_LINK
|
||||||
|
@ -2242,7 +2236,6 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
d = NULL;
|
d = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (arg_is_unicode) {
|
if (arg_is_unicode) {
|
||||||
PyObject *w;
|
PyObject *w;
|
||||||
|
|
||||||
|
@ -2259,7 +2252,6 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (PyList_Append(d, v) != 0) {
|
if (PyList_Append(d, v) != 0) {
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
Py_DECREF(d);
|
Py_DECREF(d);
|
||||||
|
@ -5764,14 +5756,11 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN];
|
||||||
char *path;
|
char *path;
|
||||||
int n;
|
int n;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
int arg_is_unicode = 0;
|
int arg_is_unicode = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "et:readlink",
|
if (!PyArg_ParseTuple(args, "et:readlink",
|
||||||
Py_FileSystemDefaultEncoding, &path))
|
Py_FileSystemDefaultEncoding, &path))
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
v = PySequence_GetItem(args, 0);
|
v = PySequence_GetItem(args, 0);
|
||||||
if (v == NULL) return NULL;
|
if (v == NULL) return NULL;
|
||||||
|
|
||||||
|
@ -5779,7 +5768,6 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||||
arg_is_unicode = 1;
|
arg_is_unicode = 1;
|
||||||
}
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
#endif
|
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
n = readlink(path, buf, (int) sizeof buf);
|
n = readlink(path, buf, (int) sizeof buf);
|
||||||
|
@ -5788,7 +5776,6 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||||
return posix_error_with_filename(path);
|
return posix_error_with_filename(path);
|
||||||
|
|
||||||
v = PyString_FromStringAndSize(buf, n);
|
v = PyString_FromStringAndSize(buf, n);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (arg_is_unicode) {
|
if (arg_is_unicode) {
|
||||||
PyObject *w;
|
PyObject *w;
|
||||||
|
|
||||||
|
@ -5805,7 +5792,6 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_READLINK */
|
#endif /* HAVE_READLINK */
|
||||||
|
@ -8184,10 +8170,8 @@ static PyMethodDef posix_methods[] = {
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETCWD
|
#ifdef HAVE_GETCWD
|
||||||
{"getcwd", posix_getcwd, METH_NOARGS, posix_getcwd__doc__},
|
{"getcwd", posix_getcwd, METH_NOARGS, posix_getcwd__doc__},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"getcwdu", posix_getcwdu, METH_NOARGS, posix_getcwdu__doc__},
|
{"getcwdu", posix_getcwdu, METH_NOARGS, posix_getcwdu__doc__},
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LINK
|
#ifdef HAVE_LINK
|
||||||
{"link", posix_link, METH_VARARGS, posix_link__doc__},
|
{"link", posix_link, METH_VARARGS, posix_link__doc__},
|
||||||
#endif /* HAVE_LINK */
|
#endif /* HAVE_LINK */
|
||||||
|
|
|
@ -22,12 +22,7 @@
|
||||||
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2)
|
|
||||||
/* In Python 2.0 and 2.1, disabling Unicode was not possible. */
|
|
||||||
#define Py_USING_UNICODE
|
|
||||||
#else
|
|
||||||
#define FIX_TRACE
|
#define FIX_TRACE
|
||||||
#endif
|
|
||||||
|
|
||||||
enum HandlerTypes {
|
enum HandlerTypes {
|
||||||
StartElement,
|
StartElement,
|
||||||
|
@ -161,7 +156,6 @@ get_handler_name(struct HandlerInfo *hinfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Convert a string of XML_Chars into a Unicode string.
|
/* Convert a string of XML_Chars into a Unicode string.
|
||||||
Returns None if str is a null pointer. */
|
Returns None if str is a null pointer. */
|
||||||
|
|
||||||
|
@ -190,7 +184,6 @@ conv_string_len_to_unicode(const XML_Char *str, int len)
|
||||||
}
|
}
|
||||||
return PyUnicode_DecodeUTF8((const char *)str, len, "strict");
|
return PyUnicode_DecodeUTF8((const char *)str, len, "strict");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convert a string of XML_Chars into an 8-bit Python string.
|
/* Convert a string of XML_Chars into an 8-bit Python string.
|
||||||
Returns None if str is a null pointer. */
|
Returns None if str is a null pointer. */
|
||||||
|
@ -418,13 +411,9 @@ call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
#define STRING_CONV_FUNC conv_string_to_utf8
|
|
||||||
#else
|
|
||||||
/* Python 2.0 and later versions, when built with Unicode support */
|
/* Python 2.0 and later versions, when built with Unicode support */
|
||||||
#define STRING_CONV_FUNC (self->returns_unicode \
|
#define STRING_CONV_FUNC (self->returns_unicode \
|
||||||
? conv_string_to_unicode : conv_string_to_utf8)
|
? conv_string_to_unicode : conv_string_to_utf8)
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
string_intern(xmlparseobject *self, const char* str)
|
string_intern(xmlparseobject *self, const char* str)
|
||||||
|
@ -460,13 +449,9 @@ call_character_handler(xmlparseobject *self, const XML_Char *buffer, int len)
|
||||||
args = PyTuple_New(1);
|
args = PyTuple_New(1);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
temp = (self->returns_unicode
|
temp = (self->returns_unicode
|
||||||
? conv_string_len_to_unicode(buffer, len)
|
? conv_string_len_to_unicode(buffer, len)
|
||||||
: conv_string_len_to_utf8(buffer, len));
|
: conv_string_len_to_utf8(buffer, len));
|
||||||
#else
|
|
||||||
temp = conv_string_len_to_utf8(buffer, len);
|
|
||||||
#endif
|
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
flag_error(self);
|
flag_error(self);
|
||||||
|
@ -674,24 +659,6 @@ VOID_HANDLER(UnparsedEntityDecl,
|
||||||
string_intern(self, systemId), string_intern(self, publicId),
|
string_intern(self, systemId), string_intern(self, publicId),
|
||||||
string_intern(self, notationName)))
|
string_intern(self, notationName)))
|
||||||
|
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
VOID_HANDLER(EntityDecl,
|
|
||||||
(void *userData,
|
|
||||||
const XML_Char *entityName,
|
|
||||||
int is_parameter_entity,
|
|
||||||
const XML_Char *value,
|
|
||||||
int value_length,
|
|
||||||
const XML_Char *base,
|
|
||||||
const XML_Char *systemId,
|
|
||||||
const XML_Char *publicId,
|
|
||||||
const XML_Char *notationName),
|
|
||||||
("NiNNNNN",
|
|
||||||
string_intern(self, entityName), is_parameter_entity,
|
|
||||||
conv_string_len_to_utf8(value, value_length),
|
|
||||||
string_intern(self, base), string_intern(self, systemId),
|
|
||||||
string_intern(self, publicId),
|
|
||||||
string_intern(self, notationName)))
|
|
||||||
#else
|
|
||||||
VOID_HANDLER(EntityDecl,
|
VOID_HANDLER(EntityDecl,
|
||||||
(void *userData,
|
(void *userData,
|
||||||
const XML_Char *entityName,
|
const XML_Char *entityName,
|
||||||
|
@ -710,7 +677,6 @@ VOID_HANDLER(EntityDecl,
|
||||||
string_intern(self, base), string_intern(self, systemId),
|
string_intern(self, base), string_intern(self, systemId),
|
||||||
string_intern(self, publicId),
|
string_intern(self, publicId),
|
||||||
string_intern(self, notationName)))
|
string_intern(self, notationName)))
|
||||||
#endif
|
|
||||||
|
|
||||||
VOID_HANDLER(XmlDecl,
|
VOID_HANDLER(XmlDecl,
|
||||||
(void *userData,
|
(void *userData,
|
||||||
|
@ -761,14 +727,10 @@ my_ElementDeclHandler(void *userData,
|
||||||
|
|
||||||
if (flush_character_buffer(self) < 0)
|
if (flush_character_buffer(self) < 0)
|
||||||
goto finally;
|
goto finally;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
modelobj = conv_content_model(model,
|
modelobj = conv_content_model(model,
|
||||||
(self->returns_unicode
|
(self->returns_unicode
|
||||||
? conv_string_to_unicode
|
? conv_string_to_unicode
|
||||||
: conv_string_to_utf8));
|
: conv_string_to_utf8));
|
||||||
#else
|
|
||||||
modelobj = conv_content_model(model, conv_string_to_utf8);
|
|
||||||
#endif
|
|
||||||
if (modelobj == NULL) {
|
if (modelobj == NULL) {
|
||||||
flag_error(self);
|
flag_error(self);
|
||||||
goto finally;
|
goto finally;
|
||||||
|
@ -856,15 +818,6 @@ VOID_HANDLER(EndCdataSection,
|
||||||
(void *userData),
|
(void *userData),
|
||||||
("()"))
|
("()"))
|
||||||
|
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
VOID_HANDLER(Default,
|
|
||||||
(void *userData, const XML_Char *s, int len),
|
|
||||||
("(N)", conv_string_len_to_utf8(s,len)))
|
|
||||||
|
|
||||||
VOID_HANDLER(DefaultHandlerExpand,
|
|
||||||
(void *userData, const XML_Char *s, int len),
|
|
||||||
("(N)", conv_string_len_to_utf8(s,len)))
|
|
||||||
#else
|
|
||||||
VOID_HANDLER(Default,
|
VOID_HANDLER(Default,
|
||||||
(void *userData, const XML_Char *s, int len),
|
(void *userData, const XML_Char *s, int len),
|
||||||
("(N)", (self->returns_unicode
|
("(N)", (self->returns_unicode
|
||||||
|
@ -876,7 +829,6 @@ VOID_HANDLER(DefaultHandlerExpand,
|
||||||
("(N)", (self->returns_unicode
|
("(N)", (self->returns_unicode
|
||||||
? conv_string_len_to_unicode(s,len)
|
? conv_string_len_to_unicode(s,len)
|
||||||
: conv_string_len_to_utf8(s,len))))
|
: conv_string_len_to_utf8(s,len))))
|
||||||
#endif
|
|
||||||
|
|
||||||
INT_HANDLER(NotStandalone,
|
INT_HANDLER(NotStandalone,
|
||||||
(void *userData),
|
(void *userData),
|
||||||
|
@ -1268,7 +1220,6 @@ static struct PyMethodDef xmlparse_methods[] = {
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
|
|
||||||
/* pyexpat international encoding support.
|
/* pyexpat international encoding support.
|
||||||
Make it as simple as possible.
|
Make it as simple as possible.
|
||||||
|
@ -1319,7 +1270,6 @@ PyUnknownEncodingHandler(void *encodingHandlerData,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
||||||
|
@ -1336,11 +1286,7 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
||||||
if (self == NULL)
|
if (self == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
self->returns_unicode = 1;
|
self->returns_unicode = 1;
|
||||||
#else
|
|
||||||
self->returns_unicode = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
self->buffer = NULL;
|
self->buffer = NULL;
|
||||||
self->buffer_size = CHARACTER_DATA_BUFFER_SIZE;
|
self->buffer_size = CHARACTER_DATA_BUFFER_SIZE;
|
||||||
|
@ -1370,10 +1316,8 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
XML_SetUserData(self->itself, (void *)self);
|
XML_SetUserData(self->itself, (void *)self);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
XML_SetUnknownEncodingHandler(self->itself,
|
XML_SetUnknownEncodingHandler(self->itself,
|
||||||
(XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL);
|
(XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; handler_info[i].name != NULL; i++)
|
for (i = 0; handler_info[i].name != NULL; i++)
|
||||||
/* do nothing */;
|
/* do nothing */;
|
||||||
|
@ -1631,13 +1575,7 @@ xmlparse_setattr(xmlparseobject *self, char *name, PyObject *v)
|
||||||
}
|
}
|
||||||
if (strcmp(name, "returns_unicode") == 0) {
|
if (strcmp(name, "returns_unicode") == 0) {
|
||||||
if (PyObject_IsTrue(v)) {
|
if (PyObject_IsTrue(v)) {
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
PyErr_SetString(PyExc_ValueError,
|
|
||||||
"Unicode support not available");
|
|
||||||
return -1;
|
|
||||||
#else
|
|
||||||
self->returns_unicode = 1;
|
self->returns_unicode = 1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
self->returns_unicode = 0;
|
self->returns_unicode = 0;
|
||||||
|
@ -1886,9 +1824,7 @@ MODULE_INITFUNC(void)
|
||||||
Py_BuildValue("(iii)", info.major,
|
Py_BuildValue("(iii)", info.major,
|
||||||
info.minor, info.micro));
|
info.minor, info.micro));
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
init_template_buffer();
|
init_template_buffer();
|
||||||
#endif
|
|
||||||
/* XXX When Expat supports some way of figuring out how it was
|
/* XXX When Expat supports some way of figuring out how it was
|
||||||
compiled, this should check and set native_encoding
|
compiled, this should check and set native_encoding
|
||||||
appropriately.
|
appropriately.
|
||||||
|
|
|
@ -931,13 +931,11 @@ PyNumber_Long(PyObject *o)
|
||||||
*/
|
*/
|
||||||
return long_from_string(PyString_AS_STRING(o),
|
return long_from_string(PyString_AS_STRING(o),
|
||||||
PyString_GET_SIZE(o));
|
PyString_GET_SIZE(o));
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(o))
|
if (PyUnicode_Check(o))
|
||||||
/* The above check is done in PyLong_FromUnicode(). */
|
/* The above check is done in PyLong_FromUnicode(). */
|
||||||
return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o),
|
return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o),
|
||||||
PyUnicode_GET_SIZE(o),
|
PyUnicode_GET_SIZE(o),
|
||||||
10);
|
10);
|
||||||
#endif
|
|
||||||
if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len))
|
if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len))
|
||||||
return long_from_string(buffer, buffer_len);
|
return long_from_string(buffer, buffer_len);
|
||||||
|
|
||||||
|
|
|
@ -696,16 +696,13 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
|
||||||
int sw_error=0;
|
int sw_error=0;
|
||||||
int sign;
|
int sign;
|
||||||
char buffer[256]; /* For errors */
|
char buffer[256]; /* For errors */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
char s_buffer[256];
|
char s_buffer[256];
|
||||||
#endif
|
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
|
|
||||||
if (PyString_Check(v)) {
|
if (PyString_Check(v)) {
|
||||||
s = PyString_AS_STRING(v);
|
s = PyString_AS_STRING(v);
|
||||||
len = PyString_GET_SIZE(v);
|
len = PyString_GET_SIZE(v);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(v)) {
|
else if (PyUnicode_Check(v)) {
|
||||||
if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) {
|
if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
@ -720,7 +717,6 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
|
||||||
s = s_buffer;
|
s = s_buffer;
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"complex() arg is not a string");
|
"complex() arg is not a string");
|
||||||
|
|
|
@ -1183,7 +1183,6 @@ SimpleExtendsException(PyExc_StandardError, ValueError,
|
||||||
SimpleExtendsException(PyExc_ValueError, UnicodeError,
|
SimpleExtendsException(PyExc_ValueError, UnicodeError,
|
||||||
"Unicode related error.");
|
"Unicode related error.");
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static int
|
static int
|
||||||
get_int(PyObject *attr, Py_ssize_t *value, const char *name)
|
get_int(PyObject *attr, Py_ssize_t *value, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -1788,7 +1787,6 @@ PyUnicodeTranslateError_Create(
|
||||||
return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns",
|
return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns",
|
||||||
object, length, start, end, reason);
|
object, length, start, end, reason);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1989,11 +1987,9 @@ _PyExc_Init(void)
|
||||||
PRE_INIT(KeyError)
|
PRE_INIT(KeyError)
|
||||||
PRE_INIT(ValueError)
|
PRE_INIT(ValueError)
|
||||||
PRE_INIT(UnicodeError)
|
PRE_INIT(UnicodeError)
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PRE_INIT(UnicodeEncodeError)
|
PRE_INIT(UnicodeEncodeError)
|
||||||
PRE_INIT(UnicodeDecodeError)
|
PRE_INIT(UnicodeDecodeError)
|
||||||
PRE_INIT(UnicodeTranslateError)
|
PRE_INIT(UnicodeTranslateError)
|
||||||
#endif
|
|
||||||
PRE_INIT(AssertionError)
|
PRE_INIT(AssertionError)
|
||||||
PRE_INIT(ArithmeticError)
|
PRE_INIT(ArithmeticError)
|
||||||
PRE_INIT(FloatingPointError)
|
PRE_INIT(FloatingPointError)
|
||||||
|
@ -2051,11 +2047,9 @@ _PyExc_Init(void)
|
||||||
POST_INIT(KeyError)
|
POST_INIT(KeyError)
|
||||||
POST_INIT(ValueError)
|
POST_INIT(ValueError)
|
||||||
POST_INIT(UnicodeError)
|
POST_INIT(UnicodeError)
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
POST_INIT(UnicodeEncodeError)
|
POST_INIT(UnicodeEncodeError)
|
||||||
POST_INIT(UnicodeDecodeError)
|
POST_INIT(UnicodeDecodeError)
|
||||||
POST_INIT(UnicodeTranslateError)
|
POST_INIT(UnicodeTranslateError)
|
||||||
#endif
|
|
||||||
POST_INIT(AssertionError)
|
POST_INIT(AssertionError)
|
||||||
POST_INIT(ArithmeticError)
|
POST_INIT(ArithmeticError)
|
||||||
POST_INIT(FloatingPointError)
|
POST_INIT(FloatingPointError)
|
||||||
|
|
|
@ -412,7 +412,6 @@ static PyObject *
|
||||||
file_repr(PyFileObject *f)
|
file_repr(PyFileObject *f)
|
||||||
{
|
{
|
||||||
if (PyUnicode_Check(f->f_name)) {
|
if (PyUnicode_Check(f->f_name)) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *ret = NULL;
|
PyObject *ret = NULL;
|
||||||
PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name);
|
PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name);
|
||||||
const char *name_str = name ? PyString_AsString(name) : "?";
|
const char *name_str = name ? PyString_AsString(name) : "?";
|
||||||
|
@ -423,7 +422,6 @@ file_repr(PyFileObject *f)
|
||||||
f);
|
f);
|
||||||
Py_XDECREF(name);
|
Py_XDECREF(name);
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
return PyString_FromFormat("<%s file '%s', mode '%s' at %p>",
|
return PyString_FromFormat("<%s file '%s', mode '%s' at %p>",
|
||||||
f->f_fp == NULL ? "closed" : "open",
|
f->f_fp == NULL ? "closed" : "open",
|
||||||
|
@ -1337,7 +1335,6 @@ PyFile_GetLine(PyObject *f, int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (n < 0 && result != NULL && PyUnicode_Check(result)) {
|
if (n < 0 && result != NULL && PyUnicode_Check(result)) {
|
||||||
Py_UNICODE *s = PyUnicode_AS_UNICODE(result);
|
Py_UNICODE *s = PyUnicode_AS_UNICODE(result);
|
||||||
Py_ssize_t len = PyUnicode_GET_SIZE(result);
|
Py_ssize_t len = PyUnicode_GET_SIZE(result);
|
||||||
|
@ -1358,7 +1355,6 @@ PyFile_GetLine(PyObject *f, int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2124,15 +2120,12 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||||
}
|
}
|
||||||
else if (PyFile_Check(f)) {
|
else if (PyFile_Check(f)) {
|
||||||
FILE *fp = PyFile_AsFile(f);
|
FILE *fp = PyFile_AsFile(f);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *enc = ((PyFileObject*)f)->f_encoding;
|
PyObject *enc = ((PyFileObject*)f)->f_encoding;
|
||||||
int result;
|
int result;
|
||||||
#endif
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
err_closed();
|
err_closed();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if ((flags & Py_PRINT_RAW) &&
|
if ((flags & Py_PRINT_RAW) &&
|
||||||
PyUnicode_Check(v) && enc != Py_None) {
|
PyUnicode_Check(v) && enc != Py_None) {
|
||||||
char *cenc = PyString_AS_STRING(enc);
|
char *cenc = PyString_AS_STRING(enc);
|
||||||
|
@ -2146,9 +2139,6 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||||
result = PyObject_Print(value, fp, flags);
|
result = PyObject_Print(value, fp, flags);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
return result;
|
return result;
|
||||||
#else
|
|
||||||
return PyObject_Print(v, fp, flags);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
writer = PyObject_GetAttrString(f, "write");
|
writer = PyObject_GetAttrString(f, "write");
|
||||||
if (writer == NULL)
|
if (writer == NULL)
|
||||||
|
|
|
@ -68,16 +68,13 @@ PyFloat_FromString(PyObject *v)
|
||||||
const char *s, *last, *end;
|
const char *s, *last, *end;
|
||||||
double x;
|
double x;
|
||||||
char buffer[256]; /* for errors */
|
char buffer[256]; /* for errors */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
char s_buffer[256]; /* for objects convertible to a char buffer */
|
char s_buffer[256]; /* for objects convertible to a char buffer */
|
||||||
#endif
|
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
|
|
||||||
if (PyString_Check(v)) {
|
if (PyString_Check(v)) {
|
||||||
s = PyString_AS_STRING(v);
|
s = PyString_AS_STRING(v);
|
||||||
len = PyString_GET_SIZE(v);
|
len = PyString_GET_SIZE(v);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(v)) {
|
else if (PyUnicode_Check(v)) {
|
||||||
if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) {
|
if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
@ -92,7 +89,6 @@ PyFloat_FromString(PyObject *v)
|
||||||
s = s_buffer;
|
s = s_buffer;
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"float() argument must be a string or a number");
|
"float() argument must be a string or a number");
|
||||||
|
|
|
@ -387,7 +387,6 @@ PyInt_FromString(char *s, char **pend, int base)
|
||||||
return PyInt_FromLong(x);
|
return PyInt_FromLong(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyInt_FromUnicode(Py_UNICODE *s, Py_ssize_t length, int base)
|
PyInt_FromUnicode(Py_UNICODE *s, Py_ssize_t length, int base)
|
||||||
{
|
{
|
||||||
|
@ -405,7 +404,6 @@ PyInt_FromUnicode(Py_UNICODE *s, Py_ssize_t length, int base)
|
||||||
PyMem_FREE(buffer);
|
PyMem_FREE(buffer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
|
@ -986,12 +984,10 @@ int_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
}
|
}
|
||||||
return PyInt_FromString(string, NULL, base);
|
return PyInt_FromString(string, NULL, base);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(x))
|
if (PyUnicode_Check(x))
|
||||||
return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x),
|
return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x),
|
||||||
PyUnicode_GET_SIZE(x),
|
PyUnicode_GET_SIZE(x),
|
||||||
base);
|
base);
|
||||||
#endif
|
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"int() can't convert non-string with explicit base");
|
"int() can't convert non-string with explicit base");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1939,7 +1939,6 @@ digit beyond the first.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
|
PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
|
||||||
{
|
{
|
||||||
|
@ -1957,7 +1956,6 @@ PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
|
||||||
PyMem_FREE(buffer);
|
PyMem_FREE(buffer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* forward */
|
/* forward */
|
||||||
static PyLongObject *x_divrem
|
static PyLongObject *x_divrem
|
||||||
|
@ -3538,12 +3536,10 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
}
|
}
|
||||||
return PyLong_FromString(PyString_AS_STRING(x), NULL, base);
|
return PyLong_FromString(PyString_AS_STRING(x), NULL, base);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(x))
|
else if (PyUnicode_Check(x))
|
||||||
return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x),
|
return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x),
|
||||||
PyUnicode_GET_SIZE(x),
|
PyUnicode_GET_SIZE(x),
|
||||||
base);
|
base);
|
||||||
#endif
|
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"int() can't convert non-string with explicit base");
|
"int() can't convert non-string with explicit base");
|
||||||
|
|
|
@ -361,7 +361,6 @@ PyObject_Repr(PyObject *v)
|
||||||
res = (*v->ob_type->tp_repr)(v);
|
res = (*v->ob_type->tp_repr)(v);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(res)) {
|
if (PyUnicode_Check(res)) {
|
||||||
PyObject* str;
|
PyObject* str;
|
||||||
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
||||||
|
@ -371,7 +370,6 @@ PyObject_Repr(PyObject *v)
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!PyString_Check(res)) {
|
if (!PyString_Check(res)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"__repr__ returned non-string (type %.200s)",
|
"__repr__ returned non-string (type %.200s)",
|
||||||
|
@ -394,12 +392,10 @@ _PyObject_Str(PyObject *v)
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_CheckExact(v)) {
|
if (PyUnicode_CheckExact(v)) {
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (v->ob_type->tp_str == NULL)
|
if (v->ob_type->tp_str == NULL)
|
||||||
return PyObject_Repr(v);
|
return PyObject_Repr(v);
|
||||||
|
|
||||||
|
@ -407,9 +403,7 @@ _PyObject_Str(PyObject *v)
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
type_ok = PyString_Check(res);
|
type_ok = PyString_Check(res);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
type_ok = type_ok || PyUnicode_Check(res);
|
type_ok = type_ok || PyUnicode_Check(res);
|
||||||
#endif
|
|
||||||
if (!type_ok) {
|
if (!type_ok) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"__str__ returned non-string (type %.200s)",
|
"__str__ returned non-string (type %.200s)",
|
||||||
|
@ -426,7 +420,6 @@ PyObject_Str(PyObject *v)
|
||||||
PyObject *res = _PyObject_Str(v);
|
PyObject *res = _PyObject_Str(v);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(res)) {
|
if (PyUnicode_Check(res)) {
|
||||||
PyObject* str;
|
PyObject* str;
|
||||||
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
||||||
|
@ -436,12 +429,10 @@ PyObject_Str(PyObject *v)
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
assert(PyString_Check(res));
|
assert(PyString_Check(res));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyObject_Unicode(PyObject *v)
|
PyObject_Unicode(PyObject *v)
|
||||||
{
|
{
|
||||||
|
@ -502,7 +493,6 @@ PyObject_Unicode(PyObject *v)
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* The new comparison philosophy is: we completely separate three-way
|
/* The new comparison philosophy is: we completely separate three-way
|
||||||
|
@ -895,7 +885,6 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
|
||||||
PyTypeObject *tp = v->ob_type;
|
PyTypeObject *tp = v->ob_type;
|
||||||
|
|
||||||
if (!PyString_Check(name)) {
|
if (!PyString_Check(name)) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* The Unicode to string conversion is done here because the
|
/* The Unicode to string conversion is done here because the
|
||||||
existing tp_getattro slots expect a string object as name
|
existing tp_getattro slots expect a string object as name
|
||||||
and we wouldn't want to break those. */
|
and we wouldn't want to break those. */
|
||||||
|
@ -905,7 +894,6 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"attribute name must be string, not '%.200s'",
|
"attribute name must be string, not '%.200s'",
|
||||||
|
@ -942,7 +930,6 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!PyString_Check(name)){
|
if (!PyString_Check(name)){
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* The Unicode to string conversion is done here because the
|
/* The Unicode to string conversion is done here because the
|
||||||
existing tp_setattro slots expect a string object as name
|
existing tp_setattro slots expect a string object as name
|
||||||
and we wouldn't want to break those. */
|
and we wouldn't want to break those. */
|
||||||
|
@ -952,7 +939,6 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"attribute name must be string, not '%.200s'",
|
"attribute name must be string, not '%.200s'",
|
||||||
|
@ -1039,7 +1025,6 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
||||||
PyObject **dictptr;
|
PyObject **dictptr;
|
||||||
|
|
||||||
if (!PyString_Check(name)){
|
if (!PyString_Check(name)){
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* The Unicode to string conversion is done here because the
|
/* The Unicode to string conversion is done here because the
|
||||||
existing tp_setattro slots expect a string object as name
|
existing tp_setattro slots expect a string object as name
|
||||||
and we wouldn't want to break those. */
|
and we wouldn't want to break those. */
|
||||||
|
@ -1049,7 +1034,6 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"attribute name must be string, not '%.200s'",
|
"attribute name must be string, not '%.200s'",
|
||||||
|
@ -1157,7 +1141,6 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (!PyString_Check(name)){
|
if (!PyString_Check(name)){
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* The Unicode to string conversion is done here because the
|
/* The Unicode to string conversion is done here because the
|
||||||
existing tp_setattro slots expect a string object as name
|
existing tp_setattro slots expect a string object as name
|
||||||
and we wouldn't want to break those. */
|
and we wouldn't want to break those. */
|
||||||
|
@ -1167,7 +1150,6 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"attribute name must be string, not '%.200s'",
|
"attribute name must be string, not '%.200s'",
|
||||||
|
|
|
@ -379,12 +379,7 @@ PyObject *PyString_AsDecodedObject(PyObject *str,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoding == NULL) {
|
if (encoding == NULL) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
encoding = PyUnicode_GetDefaultEncoding();
|
encoding = PyUnicode_GetDefaultEncoding();
|
||||||
#else
|
|
||||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
|
||||||
goto onError;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decode via the codec registry */
|
/* Decode via the codec registry */
|
||||||
|
@ -408,7 +403,6 @@ PyObject *PyString_AsDecodedString(PyObject *str,
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Convert Unicode to a string using the default encoding */
|
/* Convert Unicode to a string using the default encoding */
|
||||||
if (PyUnicode_Check(v)) {
|
if (PyUnicode_Check(v)) {
|
||||||
PyObject *temp = v;
|
PyObject *temp = v;
|
||||||
|
@ -417,7 +411,6 @@ PyObject *PyString_AsDecodedString(PyObject *str,
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!PyString_Check(v)) {
|
if (!PyString_Check(v)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"decoder did not return a string object (type=%.400s)",
|
"decoder did not return a string object (type=%.400s)",
|
||||||
|
@ -459,12 +452,7 @@ PyObject *PyString_AsEncodedObject(PyObject *str,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoding == NULL) {
|
if (encoding == NULL) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
encoding = PyUnicode_GetDefaultEncoding();
|
encoding = PyUnicode_GetDefaultEncoding();
|
||||||
#else
|
|
||||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
|
||||||
goto onError;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encode via the codec registry */
|
/* Encode via the codec registry */
|
||||||
|
@ -488,7 +476,6 @@ PyObject *PyString_AsEncodedString(PyObject *str,
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Convert Unicode to a string using the default encoding */
|
/* Convert Unicode to a string using the default encoding */
|
||||||
if (PyUnicode_Check(v)) {
|
if (PyUnicode_Check(v)) {
|
||||||
PyObject *temp = v;
|
PyObject *temp = v;
|
||||||
|
@ -497,7 +484,6 @@ PyObject *PyString_AsEncodedString(PyObject *str,
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!PyString_Check(v)) {
|
if (!PyString_Check(v)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"encoder did not return a string object (type=%.400s)",
|
"encoder did not return a string object (type=%.400s)",
|
||||||
|
@ -560,7 +546,6 @@ PyObject *PyString_DecodeEscape(const char *s,
|
||||||
while (s < end) {
|
while (s < end) {
|
||||||
if (*s != '\\') {
|
if (*s != '\\') {
|
||||||
non_esc:
|
non_esc:
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (recode_encoding && (*s & 0x80)) {
|
if (recode_encoding && (*s & 0x80)) {
|
||||||
PyObject *u, *w;
|
PyObject *u, *w;
|
||||||
char *r;
|
char *r;
|
||||||
|
@ -589,9 +574,6 @@ PyObject *PyString_DecodeEscape(const char *s,
|
||||||
} else {
|
} else {
|
||||||
*p++ = *s++;
|
*p++ = *s++;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
*p++ = *s++;
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
|
@ -663,17 +645,6 @@ PyObject *PyString_DecodeEscape(const char *s,
|
||||||
errors);
|
errors);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
case 'u':
|
|
||||||
case 'U':
|
|
||||||
case 'N':
|
|
||||||
if (unicode) {
|
|
||||||
PyErr_SetString(PyExc_ValueError,
|
|
||||||
"Unicode escapes not legal "
|
|
||||||
"when Unicode disabled");
|
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
*p++ = '\\';
|
*p++ = '\\';
|
||||||
s--;
|
s--;
|
||||||
|
@ -739,17 +710,15 @@ PyString_AsStringAndSize(register PyObject *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PyString_Check(obj)) {
|
if (!PyString_Check(obj)) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(obj)) {
|
if (PyUnicode_Check(obj)) {
|
||||||
obj = _PyUnicode_AsDefaultEncodedString(obj, NULL);
|
obj = _PyUnicode_AsDefaultEncodedString(obj, NULL);
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"expected string or Unicode object, "
|
"expected str object, "
|
||||||
"%.200s found", obj->ob_type->tp_name);
|
"%.200s found", obj->ob_type->tp_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -944,10 +913,8 @@ string_concat(register PyStringObject *a, register PyObject *bb)
|
||||||
register Py_ssize_t size;
|
register Py_ssize_t size;
|
||||||
register PyStringObject *op;
|
register PyStringObject *op;
|
||||||
if (!PyString_Check(bb)) {
|
if (!PyString_Check(bb)) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(bb))
|
if (PyUnicode_Check(bb))
|
||||||
return PyUnicode_Concat((PyObject *)a, bb);
|
return PyUnicode_Concat((PyObject *)a, bb);
|
||||||
#endif
|
|
||||||
if (PyBytes_Check(bb))
|
if (PyBytes_Check(bb))
|
||||||
return PyBytes_Concat((PyObject *)a, bb);
|
return PyBytes_Concat((PyObject *)a, bb);
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
@ -1068,10 +1035,8 @@ static int
|
||||||
string_contains(PyObject *str_obj, PyObject *sub_obj)
|
string_contains(PyObject *str_obj, PyObject *sub_obj)
|
||||||
{
|
{
|
||||||
if (!PyString_CheckExact(sub_obj)) {
|
if (!PyString_CheckExact(sub_obj)) {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(sub_obj))
|
if (PyUnicode_Check(sub_obj))
|
||||||
return PyUnicode_Contains(str_obj, sub_obj);
|
return PyUnicode_Contains(str_obj, sub_obj);
|
||||||
#endif
|
|
||||||
if (!PyString_Check(sub_obj)) {
|
if (!PyString_Check(sub_obj)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"'in <string>' requires string as left operand, "
|
"'in <string>' requires string as left operand, "
|
||||||
|
@ -1477,10 +1442,8 @@ string_split(PyStringObject *self, PyObject *args)
|
||||||
sub = PyString_AS_STRING(subobj);
|
sub = PyString_AS_STRING(subobj);
|
||||||
n = PyString_GET_SIZE(subobj);
|
n = PyString_GET_SIZE(subobj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(subobj))
|
else if (PyUnicode_Check(subobj))
|
||||||
return PyUnicode_Split((PyObject *)self, subobj, maxsplit);
|
return PyUnicode_Split((PyObject *)self, subobj, maxsplit);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
|
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1543,10 +1506,8 @@ string_partition(PyStringObject *self, PyObject *sep_obj)
|
||||||
sep = PyString_AS_STRING(sep_obj);
|
sep = PyString_AS_STRING(sep_obj);
|
||||||
sep_len = PyString_GET_SIZE(sep_obj);
|
sep_len = PyString_GET_SIZE(sep_obj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(sep_obj))
|
else if (PyUnicode_Check(sep_obj))
|
||||||
return PyUnicode_Partition((PyObject *) self, sep_obj);
|
return PyUnicode_Partition((PyObject *) self, sep_obj);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
|
else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1574,10 +1535,8 @@ string_rpartition(PyStringObject *self, PyObject *sep_obj)
|
||||||
sep = PyString_AS_STRING(sep_obj);
|
sep = PyString_AS_STRING(sep_obj);
|
||||||
sep_len = PyString_GET_SIZE(sep_obj);
|
sep_len = PyString_GET_SIZE(sep_obj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(sep_obj))
|
else if (PyUnicode_Check(sep_obj))
|
||||||
return PyUnicode_Partition((PyObject *) self, sep_obj);
|
return PyUnicode_Partition((PyObject *) self, sep_obj);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
|
else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1684,10 +1643,8 @@ string_rsplit(PyStringObject *self, PyObject *args)
|
||||||
sub = PyString_AS_STRING(subobj);
|
sub = PyString_AS_STRING(subobj);
|
||||||
n = PyString_GET_SIZE(subobj);
|
n = PyString_GET_SIZE(subobj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(subobj))
|
else if (PyUnicode_Check(subobj))
|
||||||
return PyUnicode_RSplit((PyObject *)self, subobj, maxsplit);
|
return PyUnicode_RSplit((PyObject *)self, subobj, maxsplit);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
|
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1774,7 +1731,6 @@ string_join(PyStringObject *self, PyObject *orig)
|
||||||
const size_t old_sz = sz;
|
const size_t old_sz = sz;
|
||||||
item = PySequence_Fast_GET_ITEM(seq, i);
|
item = PySequence_Fast_GET_ITEM(seq, i);
|
||||||
if (!PyString_Check(item)){
|
if (!PyString_Check(item)){
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(item)) {
|
if (PyUnicode_Check(item)) {
|
||||||
/* Defer to Unicode join.
|
/* Defer to Unicode join.
|
||||||
* CAUTION: There's no gurantee that the
|
* CAUTION: There's no gurantee that the
|
||||||
|
@ -1786,7 +1742,6 @@ string_join(PyStringObject *self, PyObject *orig)
|
||||||
Py_DECREF(seq);
|
Py_DECREF(seq);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"sequence item %zd: expected string,"
|
"sequence item %zd: expected string,"
|
||||||
" %.80s found",
|
" %.80s found",
|
||||||
|
@ -1868,11 +1823,9 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir)
|
||||||
sub = PyString_AS_STRING(subobj);
|
sub = PyString_AS_STRING(subobj);
|
||||||
sub_len = PyString_GET_SIZE(subobj);
|
sub_len = PyString_GET_SIZE(subobj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(subobj))
|
else if (PyUnicode_Check(subobj))
|
||||||
return PyUnicode_Find(
|
return PyUnicode_Find(
|
||||||
(PyObject *)self, subobj, start, end, dir);
|
(PyObject *)self, subobj, start, end, dir);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len))
|
else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len))
|
||||||
/* XXX - the "expected a character buffer object" is pretty
|
/* XXX - the "expected a character buffer object" is pretty
|
||||||
confusing for a non-expert. remap to something else ? */
|
confusing for a non-expert. remap to something else ? */
|
||||||
|
@ -2041,7 +1994,6 @@ do_argstrip(PyStringObject *self, int striptype, PyObject *args)
|
||||||
if (sep != NULL && sep != Py_None) {
|
if (sep != NULL && sep != Py_None) {
|
||||||
if (PyString_Check(sep))
|
if (PyString_Check(sep))
|
||||||
return do_xstrip(self, striptype, sep);
|
return do_xstrip(self, striptype, sep);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(sep)) {
|
else if (PyUnicode_Check(sep)) {
|
||||||
PyObject *uniself = PyUnicode_FromObject((PyObject *)self);
|
PyObject *uniself = PyUnicode_FromObject((PyObject *)self);
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
|
@ -2052,13 +2004,8 @@ do_argstrip(PyStringObject *self, int striptype, PyObject *args)
|
||||||
Py_DECREF(uniself);
|
Py_DECREF(uniself);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
"%s arg must be None, str or unicode",
|
|
||||||
#else
|
|
||||||
"%s arg must be None or str",
|
"%s arg must be None or str",
|
||||||
#endif
|
|
||||||
STRIPNAME(striptype));
|
STRIPNAME(striptype));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2068,7 +2015,7 @@ do_argstrip(PyStringObject *self, int striptype, PyObject *args)
|
||||||
|
|
||||||
|
|
||||||
PyDoc_STRVAR(strip__doc__,
|
PyDoc_STRVAR(strip__doc__,
|
||||||
"S.strip([chars]) -> string or unicode\n\
|
"S.strip([chars]) -> str\n\
|
||||||
\n\
|
\n\
|
||||||
Return a copy of the string S with leading and trailing\n\
|
Return a copy of the string S with leading and trailing\n\
|
||||||
whitespace removed.\n\
|
whitespace removed.\n\
|
||||||
|
@ -2086,7 +2033,7 @@ string_strip(PyStringObject *self, PyObject *args)
|
||||||
|
|
||||||
|
|
||||||
PyDoc_STRVAR(lstrip__doc__,
|
PyDoc_STRVAR(lstrip__doc__,
|
||||||
"S.lstrip([chars]) -> string or unicode\n\
|
"S.lstrip([chars]) -> str\n\
|
||||||
\n\
|
\n\
|
||||||
Return a copy of the string S with leading whitespace removed.\n\
|
Return a copy of the string S with leading whitespace removed.\n\
|
||||||
If chars is given and not None, remove characters in chars instead.\n\
|
If chars is given and not None, remove characters in chars instead.\n\
|
||||||
|
@ -2103,7 +2050,7 @@ string_lstrip(PyStringObject *self, PyObject *args)
|
||||||
|
|
||||||
|
|
||||||
PyDoc_STRVAR(rstrip__doc__,
|
PyDoc_STRVAR(rstrip__doc__,
|
||||||
"S.rstrip([chars]) -> string or unicode\n\
|
"S.rstrip([chars]) -> str\n\
|
||||||
\n\
|
\n\
|
||||||
Return a copy of the string S with trailing whitespace removed.\n\
|
Return a copy of the string S with trailing whitespace removed.\n\
|
||||||
If chars is given and not None, remove characters in chars instead.\n\
|
If chars is given and not None, remove characters in chars instead.\n\
|
||||||
|
@ -2281,7 +2228,6 @@ string_count(PyStringObject *self, PyObject *args)
|
||||||
sub = PyString_AS_STRING(sub_obj);
|
sub = PyString_AS_STRING(sub_obj);
|
||||||
sub_len = PyString_GET_SIZE(sub_obj);
|
sub_len = PyString_GET_SIZE(sub_obj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(sub_obj)) {
|
else if (PyUnicode_Check(sub_obj)) {
|
||||||
Py_ssize_t count;
|
Py_ssize_t count;
|
||||||
count = PyUnicode_Count((PyObject *)self, sub_obj, start, end);
|
count = PyUnicode_Count((PyObject *)self, sub_obj, start, end);
|
||||||
|
@ -2290,7 +2236,6 @@ string_count(PyStringObject *self, PyObject *args)
|
||||||
else
|
else
|
||||||
return PyInt_FromSsize_t(count);
|
return PyInt_FromSsize_t(count);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len))
|
else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -2367,7 +2312,6 @@ string_translate(PyStringObject *self, PyObject *args)
|
||||||
table = NULL;
|
table = NULL;
|
||||||
tablen = 256;
|
tablen = 256;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(tableobj)) {
|
else if (PyUnicode_Check(tableobj)) {
|
||||||
/* Unicode .translate() does not support the deletechars
|
/* Unicode .translate() does not support the deletechars
|
||||||
parameter; instead a mapping to None will cause characters
|
parameter; instead a mapping to None will cause characters
|
||||||
|
@ -2379,7 +2323,6 @@ string_translate(PyStringObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
return PyUnicode_Translate((PyObject *)self, tableobj, NULL);
|
return PyUnicode_Translate((PyObject *)self, tableobj, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(tableobj, &table, &tablen))
|
else if (PyObject_AsCharBuffer(tableobj, &table, &tablen))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -2394,13 +2337,11 @@ string_translate(PyStringObject *self, PyObject *args)
|
||||||
del_table = PyString_AS_STRING(delobj);
|
del_table = PyString_AS_STRING(delobj);
|
||||||
dellen = PyString_GET_SIZE(delobj);
|
dellen = PyString_GET_SIZE(delobj);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(delobj)) {
|
else if (PyUnicode_Check(delobj)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"deletions are implemented differently for unicode");
|
"deletions are implemented differently for unicode");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen))
|
else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -3069,11 +3010,9 @@ string_replace(PyStringObject *self, PyObject *args)
|
||||||
from_s = PyString_AS_STRING(from);
|
from_s = PyString_AS_STRING(from);
|
||||||
from_len = PyString_GET_SIZE(from);
|
from_len = PyString_GET_SIZE(from);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(from))
|
if (PyUnicode_Check(from))
|
||||||
return PyUnicode_Replace((PyObject *)self,
|
return PyUnicode_Replace((PyObject *)self,
|
||||||
from, to, count);
|
from, to, count);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(from, &from_s, &from_len))
|
else if (PyObject_AsCharBuffer(from, &from_s, &from_len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -3081,11 +3020,9 @@ string_replace(PyStringObject *self, PyObject *args)
|
||||||
to_s = PyString_AS_STRING(to);
|
to_s = PyString_AS_STRING(to);
|
||||||
to_len = PyString_GET_SIZE(to);
|
to_len = PyString_GET_SIZE(to);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(to))
|
else if (PyUnicode_Check(to))
|
||||||
return PyUnicode_Replace((PyObject *)self,
|
return PyUnicode_Replace((PyObject *)self,
|
||||||
from, to, count);
|
from, to, count);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(to, &to_s, &to_len))
|
else if (PyObject_AsCharBuffer(to, &to_s, &to_len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -3113,11 +3050,9 @@ _string_tailmatch(PyStringObject *self, PyObject *substr, Py_ssize_t start,
|
||||||
sub = PyString_AS_STRING(substr);
|
sub = PyString_AS_STRING(substr);
|
||||||
slen = PyString_GET_SIZE(substr);
|
slen = PyString_GET_SIZE(substr);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(substr))
|
else if (PyUnicode_Check(substr))
|
||||||
return PyUnicode_Tailmatch((PyObject *)self,
|
return PyUnicode_Tailmatch((PyObject *)self,
|
||||||
substr, start, end, direction);
|
substr, start, end, direction);
|
||||||
#endif
|
|
||||||
else if (PyObject_AsCharBuffer(substr, &sub, &slen))
|
else if (PyObject_AsCharBuffer(substr, &sub, &slen))
|
||||||
return -1;
|
return -1;
|
||||||
str = PyString_AS_STRING(self);
|
str = PyString_AS_STRING(self);
|
||||||
|
@ -4009,7 +3944,7 @@ static PyObject *str_iter(PyObject *seq);
|
||||||
PyTypeObject PyString_Type = {
|
PyTypeObject PyString_Type = {
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
PyObject_HEAD_INIT(&PyType_Type)
|
||||||
0,
|
0,
|
||||||
"str8",
|
"str",
|
||||||
sizeof(PyStringObject),
|
sizeof(PyStringObject),
|
||||||
sizeof(char),
|
sizeof(char),
|
||||||
string_dealloc, /* tp_dealloc */
|
string_dealloc, /* tp_dealloc */
|
||||||
|
@ -4458,9 +4393,7 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
Py_ssize_t reslen, rescnt, fmtcnt;
|
Py_ssize_t reslen, rescnt, fmtcnt;
|
||||||
int args_owned = 0;
|
int args_owned = 0;
|
||||||
PyObject *result, *orig_args;
|
PyObject *result, *orig_args;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *v, *w;
|
PyObject *v, *w;
|
||||||
#endif
|
|
||||||
PyObject *dict = NULL;
|
PyObject *dict = NULL;
|
||||||
if (format == NULL || !PyString_Check(format) || args == NULL) {
|
if (format == NULL || !PyString_Check(format) || args == NULL) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -4512,10 +4445,8 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
char formatbuf[FORMATBUFLEN];
|
char formatbuf[FORMATBUFLEN];
|
||||||
/* For format{float,int,char}() */
|
/* For format{float,int,char}() */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
char *fmt_start = fmt;
|
char *fmt_start = fmt;
|
||||||
Py_ssize_t argidx_start = argidx;
|
Py_ssize_t argidx_start = argidx;
|
||||||
#endif
|
|
||||||
|
|
||||||
fmt++;
|
fmt++;
|
||||||
if (*fmt == '(') {
|
if (*fmt == '(') {
|
||||||
|
@ -4669,22 +4600,18 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
len = 1;
|
len = 1;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(v)) {
|
if (PyUnicode_Check(v)) {
|
||||||
fmt = fmt_start;
|
fmt = fmt_start;
|
||||||
argidx = argidx_start;
|
argidx = argidx_start;
|
||||||
goto unicode;
|
goto unicode;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
temp = _PyObject_Str(v);
|
temp = _PyObject_Str(v);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (temp != NULL && PyUnicode_Check(temp)) {
|
if (temp != NULL && PyUnicode_Check(temp)) {
|
||||||
Py_DECREF(temp);
|
Py_DECREF(temp);
|
||||||
fmt = fmt_start;
|
fmt = fmt_start;
|
||||||
argidx = argidx_start;
|
argidx = argidx_start;
|
||||||
goto unicode;
|
goto unicode;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case 'r':
|
case 'r':
|
||||||
if (c == 'r')
|
if (c == 'r')
|
||||||
|
@ -4749,13 +4676,11 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
fill = '0';
|
fill = '0';
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(v)) {
|
if (PyUnicode_Check(v)) {
|
||||||
fmt = fmt_start;
|
fmt = fmt_start;
|
||||||
argidx = argidx_start;
|
argidx = argidx_start;
|
||||||
goto unicode;
|
goto unicode;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pbuf = formatbuf;
|
pbuf = formatbuf;
|
||||||
len = formatchar(pbuf, sizeof(formatbuf), v);
|
len = formatchar(pbuf, sizeof(formatbuf), v);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
|
@ -4864,7 +4789,6 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
_PyString_Resize(&result, reslen - rescnt);
|
_PyString_Resize(&result, reslen - rescnt);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
unicode:
|
unicode:
|
||||||
if (args_owned) {
|
if (args_owned) {
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
@ -4909,7 +4833,6 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
return w;
|
return w;
|
||||||
#endif /* Py_USING_UNICODE */
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
|
|
|
@ -1505,7 +1505,6 @@ valid_identifier(PyObject *s)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Replace Unicode objects in slots. */
|
/* Replace Unicode objects in slots. */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1539,7 +1538,6 @@ _unicode_to_string(PyObject *slots, Py_ssize_t nslots)
|
||||||
}
|
}
|
||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Forward */
|
/* Forward */
|
||||||
static int
|
static int
|
||||||
|
@ -1713,7 +1711,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
tmp = _unicode_to_string(slots, nslots);
|
tmp = _unicode_to_string(slots, nslots);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
goto bad_slots;
|
goto bad_slots;
|
||||||
|
@ -1721,7 +1718,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
Py_DECREF(slots);
|
Py_DECREF(slots);
|
||||||
slots = tmp;
|
slots = tmp;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Check for valid slot names and two special cases */
|
/* Check for valid slot names and two special cases */
|
||||||
for (i = 0; i < nslots; i++) {
|
for (i = 0; i < nslots; i++) {
|
||||||
PyObject *tmp = PyTuple_GET_ITEM(slots, i);
|
PyObject *tmp = PyTuple_GET_ITEM(slots, i);
|
||||||
|
|
|
@ -475,9 +475,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
|
||||||
/* Define if you want to use the GNU readline library */
|
/* Define if you want to use the GNU readline library */
|
||||||
/* #define WITH_READLINE 1 */
|
/* #define WITH_READLINE 1 */
|
||||||
|
|
||||||
/* Define if you want to have a Unicode type. */
|
|
||||||
#define Py_USING_UNICODE
|
|
||||||
|
|
||||||
/* Define as the integral type used for Unicode representation. */
|
/* Define as the integral type used for Unicode representation. */
|
||||||
#define PY_UNICODE_TYPE unsigned short
|
#define PY_UNICODE_TYPE unsigned short
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,6 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
|
||||||
strcmp(cs, "iso-8859-1") == 0) {
|
strcmp(cs, "iso-8859-1") == 0) {
|
||||||
tok->encoding = cs;
|
tok->encoding = cs;
|
||||||
} else {
|
} else {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
r = set_readline(tok, cs);
|
r = set_readline(tok, cs);
|
||||||
if (r) {
|
if (r) {
|
||||||
tok->encoding = cs;
|
tok->encoding = cs;
|
||||||
|
@ -280,13 +279,6 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PyMem_FREE(cs);
|
PyMem_FREE(cs);
|
||||||
#else
|
|
||||||
/* Without Unicode support, we cannot
|
|
||||||
process the coding spec. Since there
|
|
||||||
won't be any Unicode literals, that
|
|
||||||
won't matter. */
|
|
||||||
PyMem_FREE(cs);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else { /* then, compare cs with BOM */
|
} else { /* then, compare cs with BOM */
|
||||||
r = (strcmp(tok->encoding, cs) == 0);
|
r = (strcmp(tok->encoding, cs) == 0);
|
||||||
|
@ -363,11 +355,6 @@ check_bom(int get_char(struct tok_state *),
|
||||||
static char *
|
static char *
|
||||||
fp_readl(char *s, int size, struct tok_state *tok)
|
fp_readl(char *s, int size, struct tok_state *tok)
|
||||||
{
|
{
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
/* In a non-Unicode built, this should never be called. */
|
|
||||||
Py_FatalError("fp_readl should not be called in this build.");
|
|
||||||
return NULL; /* Keep compiler happy (not reachable) */
|
|
||||||
#else
|
|
||||||
PyObject* utf8 = NULL;
|
PyObject* utf8 = NULL;
|
||||||
PyObject* buf = tok->decoding_buffer;
|
PyObject* buf = tok->decoding_buffer;
|
||||||
char *str;
|
char *str;
|
||||||
|
@ -407,7 +394,6 @@ fp_readl(char *s, int size, struct tok_state *tok)
|
||||||
Py_DECREF(utf8);
|
Py_DECREF(utf8);
|
||||||
if (utf8len == 0) return NULL; /* EOF */
|
if (utf8len == 0) return NULL; /* EOF */
|
||||||
return s;
|
return s;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the readline function for TOK to a StreamReader's
|
/* Set the readline function for TOK to a StreamReader's
|
||||||
|
@ -564,7 +550,6 @@ buf_setreadl(struct tok_state *tok, const char* enc) {
|
||||||
/* Return a UTF-8 encoding Python string object from the
|
/* Return a UTF-8 encoding Python string object from the
|
||||||
C byte string STR, which is encoded with ENC. */
|
C byte string STR, which is encoded with ENC. */
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
translate_into_utf8(const char* str, const char* enc) {
|
translate_into_utf8(const char* str, const char* enc) {
|
||||||
PyObject *utf8;
|
PyObject *utf8;
|
||||||
|
@ -575,7 +560,6 @@ translate_into_utf8(const char* str, const char* enc) {
|
||||||
Py_DECREF(buf);
|
Py_DECREF(buf);
|
||||||
return utf8;
|
return utf8;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Decode a byte string STR for use as the buffer of TOK.
|
/* Decode a byte string STR for use as the buffer of TOK.
|
||||||
Look for encoding declarations inside STR, and record them
|
Look for encoding declarations inside STR, and record them
|
||||||
|
@ -593,14 +577,12 @@ decode_str(const char *str, struct tok_state *tok)
|
||||||
return error_ret(tok);
|
return error_ret(tok);
|
||||||
str = tok->str; /* string after BOM if any */
|
str = tok->str; /* string after BOM if any */
|
||||||
assert(str);
|
assert(str);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (tok->enc != NULL) {
|
if (tok->enc != NULL) {
|
||||||
utf8 = translate_into_utf8(str, tok->enc);
|
utf8 = translate_into_utf8(str, tok->enc);
|
||||||
if (utf8 == NULL)
|
if (utf8 == NULL)
|
||||||
return error_ret(tok);
|
return error_ret(tok);
|
||||||
str = PyString_AsString(utf8);
|
str = PyString_AsString(utf8);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
for (s = str;; s++) {
|
for (s = str;; s++) {
|
||||||
if (*s == '\0') break;
|
if (*s == '\0') break;
|
||||||
else if (*s == '\n') {
|
else if (*s == '\n') {
|
||||||
|
@ -611,7 +593,6 @@ decode_str(const char *str, struct tok_state *tok)
|
||||||
tok->enc = NULL;
|
tok->enc = NULL;
|
||||||
if (!check_coding_spec(str, s - str, tok, buf_setreadl))
|
if (!check_coding_spec(str, s - str, tok, buf_setreadl))
|
||||||
return error_ret(tok);
|
return error_ret(tok);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (tok->enc != NULL) {
|
if (tok->enc != NULL) {
|
||||||
assert(utf8 == NULL);
|
assert(utf8 == NULL);
|
||||||
utf8 = translate_into_utf8(str, tok->enc);
|
utf8 = translate_into_utf8(str, tok->enc);
|
||||||
|
@ -622,7 +603,6 @@ decode_str(const char *str, struct tok_state *tok)
|
||||||
}
|
}
|
||||||
str = PyString_AsString(utf8);
|
str = PyString_AsString(utf8);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
assert(tok->decoding_buffer == NULL);
|
assert(tok->decoding_buffer == NULL);
|
||||||
tok->decoding_buffer = utf8; /* CAUTION */
|
tok->decoding_buffer = utf8; /* CAUTION */
|
||||||
return str;
|
return str;
|
||||||
|
@ -687,7 +667,7 @@ PyTokenizer_Free(struct tok_state *tok)
|
||||||
PyMem_FREE(tok);
|
PyMem_FREE(tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PGEN) && defined(Py_USING_UNICODE)
|
#if !defined(PGEN)
|
||||||
static int
|
static int
|
||||||
tok_stdin_decode(struct tok_state *tok, char **inp)
|
tok_stdin_decode(struct tok_state *tok, char **inp)
|
||||||
{
|
{
|
||||||
|
@ -786,7 +766,7 @@ tok_nextc(register struct tok_state *tok)
|
||||||
PyMem_FREE(newtok);
|
PyMem_FREE(newtok);
|
||||||
tok->done = E_EOF;
|
tok->done = E_EOF;
|
||||||
}
|
}
|
||||||
#if !defined(PGEN) && defined(Py_USING_UNICODE)
|
#if !defined(PGEN)
|
||||||
else if (tok_stdin_decode(tok, &newtok) != 0)
|
else if (tok_stdin_decode(tok, &newtok) != 0)
|
||||||
PyMem_FREE(newtok);
|
PyMem_FREE(newtok);
|
||||||
#endif
|
#endif
|
||||||
|
|
16
Python/ast.c
16
Python/ast.c
|
@ -3050,10 +3050,6 @@ parsenumber(const char *s)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
decode_utf8(const char **sPtr, const char *end, char* encoding)
|
decode_utf8(const char **sPtr, const char *end, char* encoding)
|
||||||
{
|
{
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
Py_FatalError("decode_utf8 should not be called in this build.");
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
PyObject *u, *v;
|
PyObject *u, *v;
|
||||||
char *s, *t;
|
char *s, *t;
|
||||||
t = s = (char *)*sPtr;
|
t = s = (char *)*sPtr;
|
||||||
|
@ -3066,7 +3062,6 @@ decode_utf8(const char **sPtr, const char *end, char* encoding)
|
||||||
v = PyUnicode_AsEncodedString(u, encoding, NULL);
|
v = PyUnicode_AsEncodedString(u, encoding, NULL);
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
return v;
|
return v;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -3186,11 +3181,9 @@ parsestr(const node *n, const char *encoding, int *bytesmode)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (!*bytesmode) {
|
if (!*bytesmode) {
|
||||||
return decode_unicode(s, len, rawmode, encoding);
|
return decode_unicode(s, len, rawmode, encoding);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (*bytesmode) {
|
if (*bytesmode) {
|
||||||
/* Disallow non-ascii characters (but not escapes) */
|
/* Disallow non-ascii characters (but not escapes) */
|
||||||
const char *c;
|
const char *c;
|
||||||
|
@ -3207,19 +3200,12 @@ parsestr(const node *n, const char *encoding, int *bytesmode)
|
||||||
strcmp(encoding, "iso-8859-1") != 0);
|
strcmp(encoding, "iso-8859-1") != 0);
|
||||||
if (rawmode || strchr(s, '\\') == NULL) {
|
if (rawmode || strchr(s, '\\') == NULL) {
|
||||||
if (need_encoding) {
|
if (need_encoding) {
|
||||||
#ifndef Py_USING_UNICODE
|
|
||||||
/* This should not happen - we never see any other
|
|
||||||
encoding. */
|
|
||||||
Py_FatalError(
|
|
||||||
"cannot deal with encodings in this build.");
|
|
||||||
#else
|
|
||||||
PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
|
PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
|
||||||
if (u == NULL)
|
if (u == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
v = PyUnicode_AsEncodedString(u, encoding, NULL);
|
v = PyUnicode_AsEncodedString(u, encoding, NULL);
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
return v;
|
return v;
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
return PyString_FromStringAndSize(s, len);
|
return PyString_FromStringAndSize(s, len);
|
||||||
}
|
}
|
||||||
|
@ -3258,7 +3244,6 @@ parsestrplus(struct compiling *c, const node *n, int *bytesmode)
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else {
|
else {
|
||||||
PyObject *temp = PyUnicode_Concat(v, s);
|
PyObject *temp = PyUnicode_Concat(v, s);
|
||||||
Py_DECREF(s);
|
Py_DECREF(s);
|
||||||
|
@ -3267,7 +3252,6 @@ parsestrplus(struct compiling *c, const node *n, int *bytesmode)
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
|
|
@ -25,9 +25,7 @@ const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
|
||||||
|
|
||||||
/* Forward */
|
/* Forward */
|
||||||
static PyObject *filterstring(PyObject *, PyObject *);
|
static PyObject *filterstring(PyObject *, PyObject *);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static PyObject *filterunicode(PyObject *, PyObject *);
|
static PyObject *filterunicode(PyObject *, PyObject *);
|
||||||
#endif
|
|
||||||
static PyObject *filtertuple (PyObject *, PyObject *);
|
static PyObject *filtertuple (PyObject *, PyObject *);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -272,10 +270,8 @@ builtin_filter(PyObject *self, PyObject *args)
|
||||||
/* Strings and tuples return a result of the same type. */
|
/* Strings and tuples return a result of the same type. */
|
||||||
if (PyString_Check(seq))
|
if (PyString_Check(seq))
|
||||||
return filterstring(func, seq);
|
return filterstring(func, seq);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(seq))
|
if (PyUnicode_Check(seq))
|
||||||
return filterunicode(func, seq);
|
return filterunicode(func, seq);
|
||||||
#endif
|
|
||||||
if (PyTuple_Check(seq))
|
if (PyTuple_Check(seq))
|
||||||
return filtertuple(func, seq);
|
return filtertuple(func, seq);
|
||||||
|
|
||||||
|
@ -381,7 +377,6 @@ PyDoc_STRVAR(filter_doc,
|
||||||
"or string, return the same type, else return a list.");
|
"or string, return the same type, else return a list.");
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
builtin_unichr(PyObject *self, PyObject *args)
|
builtin_unichr(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
@ -397,7 +392,6 @@ PyDoc_STRVAR(unichr_doc,
|
||||||
"chr(i) -> Unicode character\n\
|
"chr(i) -> Unicode character\n\
|
||||||
\n\
|
\n\
|
||||||
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.");
|
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.");
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -440,7 +434,6 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
cf.cf_flags = supplied_flags;
|
cf.cf_flags = supplied_flags;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(cmd)) {
|
if (PyUnicode_Check(cmd)) {
|
||||||
tmp = PyUnicode_AsUTF8String(cmd);
|
tmp = PyUnicode_AsUTF8String(cmd);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
|
@ -448,7 +441,6 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
cmd = tmp;
|
cmd = tmp;
|
||||||
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
|
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (PyObject_AsReadBuffer(cmd, (const void **)&str, &length))
|
if (PyObject_AsReadBuffer(cmd, (const void **)&str, &length))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((size_t)length != strlen(str)) {
|
if ((size_t)length != strlen(str)) {
|
||||||
|
@ -600,7 +592,6 @@ builtin_eval(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
cf.cf_flags = 0;
|
cf.cf_flags = 0;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(cmd)) {
|
if (PyUnicode_Check(cmd)) {
|
||||||
tmp = PyUnicode_AsUTF8String(cmd);
|
tmp = PyUnicode_AsUTF8String(cmd);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
|
@ -608,7 +599,6 @@ builtin_eval(PyObject *self, PyObject *args)
|
||||||
cmd = tmp;
|
cmd = tmp;
|
||||||
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
|
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (PyString_AsStringAndSize(cmd, &str, NULL)) {
|
if (PyString_AsStringAndSize(cmd, &str, NULL)) {
|
||||||
Py_XDECREF(tmp);
|
Py_XDECREF(tmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -708,7 +698,6 @@ builtin_exec(PyObject *self, PyObject *args)
|
||||||
char *str;
|
char *str;
|
||||||
PyCompilerFlags cf;
|
PyCompilerFlags cf;
|
||||||
cf.cf_flags = 0;
|
cf.cf_flags = 0;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(prog)) {
|
if (PyUnicode_Check(prog)) {
|
||||||
tmp = PyUnicode_AsUTF8String(prog);
|
tmp = PyUnicode_AsUTF8String(prog);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
|
@ -716,7 +705,6 @@ builtin_exec(PyObject *self, PyObject *args)
|
||||||
prog = tmp;
|
prog = tmp;
|
||||||
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
|
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (PyString_AsStringAndSize(prog, &str, NULL))
|
if (PyString_AsStringAndSize(prog, &str, NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (PyEval_MergeCompilerFlags(&cf))
|
if (PyEval_MergeCompilerFlags(&cf))
|
||||||
|
@ -850,13 +838,11 @@ builtin_getattr(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt))
|
if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt))
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(name)) {
|
if (PyUnicode_Check(name)) {
|
||||||
name = _PyUnicode_AsDefaultEncodedString(name, NULL);
|
name = _PyUnicode_AsDefaultEncodedString(name, NULL);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!PyString_Check(name)) {
|
if (!PyString_Check(name)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
@ -906,13 +892,11 @@ builtin_hasattr(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_UnpackTuple(args, "hasattr", 2, 2, &v, &name))
|
if (!PyArg_UnpackTuple(args, "hasattr", 2, 2, &v, &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(name)) {
|
if (PyUnicode_Check(name)) {
|
||||||
name = _PyUnicode_AsDefaultEncodedString(name, NULL);
|
name = _PyUnicode_AsDefaultEncodedString(name, NULL);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!PyString_Check(name)) {
|
if (!PyString_Check(name)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
@ -1471,7 +1455,6 @@ builtin_ord(PyObject *self, PyObject* obj)
|
||||||
ord = (long)((unsigned char)*PyString_AS_STRING(obj));
|
ord = (long)((unsigned char)*PyString_AS_STRING(obj));
|
||||||
return PyInt_FromLong(ord);
|
return PyInt_FromLong(ord);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
}
|
}
|
||||||
else if (PyUnicode_Check(obj)) {
|
else if (PyUnicode_Check(obj)) {
|
||||||
size = PyUnicode_GET_SIZE(obj);
|
size = PyUnicode_GET_SIZE(obj);
|
||||||
|
@ -1479,7 +1462,6 @@ builtin_ord(PyObject *self, PyObject* obj)
|
||||||
ord = (long)*PyUnicode_AS_UNICODE(obj);
|
ord = (long)*PyUnicode_AS_UNICODE(obj);
|
||||||
return PyInt_FromLong(ord);
|
return PyInt_FromLong(ord);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (PyBytes_Check(obj)) {
|
else if (PyBytes_Check(obj)) {
|
||||||
/* XXX Hopefully this is temporary */
|
/* XXX Hopefully this is temporary */
|
||||||
|
@ -2356,9 +2338,7 @@ _PyBuiltin_Init(void)
|
||||||
SETBUILTIN("tuple", &PyTuple_Type);
|
SETBUILTIN("tuple", &PyTuple_Type);
|
||||||
SETBUILTIN("type", &PyType_Type);
|
SETBUILTIN("type", &PyType_Type);
|
||||||
SETBUILTIN("xrange", &PyRange_Type);
|
SETBUILTIN("xrange", &PyRange_Type);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
SETBUILTIN("unicode", &PyUnicode_Type);
|
SETBUILTIN("unicode", &PyUnicode_Type);
|
||||||
#endif
|
|
||||||
debug = PyBool_FromLong(Py_OptimizeFlag == 0);
|
debug = PyBool_FromLong(Py_OptimizeFlag == 0);
|
||||||
if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
|
if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
|
||||||
Py_XDECREF(debug);
|
Py_XDECREF(debug);
|
||||||
|
@ -2536,7 +2516,6 @@ Fail_1:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Helper for filter(): filter a Unicode object through a function */
|
/* Helper for filter(): filter a Unicode object through a function */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -2630,4 +2609,3 @@ Fail_1:
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -468,7 +468,6 @@ PyObject *PyCodec_StrictErrors(PyObject *exc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *PyCodec_IgnoreErrors(PyObject *exc)
|
PyObject *PyCodec_IgnoreErrors(PyObject *exc)
|
||||||
{
|
{
|
||||||
Py_ssize_t end;
|
Py_ssize_t end;
|
||||||
|
@ -729,7 +728,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -737,7 +735,6 @@ 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);
|
||||||
|
@ -760,7 +757,6 @@ static PyObject *backslashreplace_errors(PyObject *self, PyObject *exc)
|
||||||
{
|
{
|
||||||
return PyCodec_BackslashReplaceErrors(exc);
|
return PyCodec_BackslashReplaceErrors(exc);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int _PyCodecRegistry_Init(void)
|
static int _PyCodecRegistry_Init(void)
|
||||||
{
|
{
|
||||||
|
@ -777,7 +773,6 @@ static int _PyCodecRegistry_Init(void)
|
||||||
METH_O
|
METH_O
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{
|
{
|
||||||
"ignore",
|
"ignore",
|
||||||
{
|
{
|
||||||
|
@ -810,7 +805,6 @@ static int _PyCodecRegistry_Init(void)
|
||||||
METH_O
|
METH_O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
|
|
|
@ -547,9 +547,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
|
|
||||||
const char *format = *p_format;
|
const char *format = *p_format;
|
||||||
char c = *format++;
|
char c = *format++;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *uarg;
|
PyObject *uarg;
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
|
||||||
|
@ -780,7 +778,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
*p = PyString_AS_STRING(arg);
|
*p = PyString_AS_STRING(arg);
|
||||||
STORE_SIZE(PyString_GET_SIZE(arg));
|
STORE_SIZE(PyString_GET_SIZE(arg));
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(arg)) {
|
else if (PyUnicode_Check(arg)) {
|
||||||
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
||||||
if (uarg == NULL)
|
if (uarg == NULL)
|
||||||
|
@ -789,7 +786,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
*p = PyString_AS_STRING(uarg);
|
*p = PyString_AS_STRING(uarg);
|
||||||
STORE_SIZE(PyString_GET_SIZE(uarg));
|
STORE_SIZE(PyString_GET_SIZE(uarg));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else { /* any buffer-like object */
|
else { /* any buffer-like object */
|
||||||
char *buf;
|
char *buf;
|
||||||
Py_ssize_t count = convertbuffer(arg, p, &buf);
|
Py_ssize_t count = convertbuffer(arg, p, &buf);
|
||||||
|
@ -803,7 +799,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
|
|
||||||
if (PyString_Check(arg))
|
if (PyString_Check(arg))
|
||||||
*p = PyString_AS_STRING(arg);
|
*p = PyString_AS_STRING(arg);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(arg)) {
|
else if (PyUnicode_Check(arg)) {
|
||||||
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
||||||
if (uarg == NULL)
|
if (uarg == NULL)
|
||||||
|
@ -811,7 +806,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
arg, msgbuf, bufsize);
|
arg, msgbuf, bufsize);
|
||||||
*p = PyString_AS_STRING(uarg);
|
*p = PyString_AS_STRING(uarg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
return converterr("string", arg, msgbuf, bufsize);
|
return converterr("string", arg, msgbuf, bufsize);
|
||||||
if ((Py_ssize_t)strlen(*p) != PyString_Size(arg))
|
if ((Py_ssize_t)strlen(*p) != PyString_Size(arg))
|
||||||
|
@ -834,7 +828,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
*p = PyString_AS_STRING(arg);
|
*p = PyString_AS_STRING(arg);
|
||||||
STORE_SIZE(PyString_GET_SIZE(arg));
|
STORE_SIZE(PyString_GET_SIZE(arg));
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(arg)) {
|
else if (PyUnicode_Check(arg)) {
|
||||||
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
||||||
if (uarg == NULL)
|
if (uarg == NULL)
|
||||||
|
@ -843,7 +836,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
*p = PyString_AS_STRING(uarg);
|
*p = PyString_AS_STRING(uarg);
|
||||||
STORE_SIZE(PyString_GET_SIZE(uarg));
|
STORE_SIZE(PyString_GET_SIZE(uarg));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else { /* any buffer-like object */
|
else { /* any buffer-like object */
|
||||||
char *buf;
|
char *buf;
|
||||||
Py_ssize_t count = convertbuffer(arg, p, &buf);
|
Py_ssize_t count = convertbuffer(arg, p, &buf);
|
||||||
|
@ -859,7 +851,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
*p = 0;
|
*p = 0;
|
||||||
else if (PyString_Check(arg))
|
else if (PyString_Check(arg))
|
||||||
*p = PyString_AS_STRING(arg);
|
*p = PyString_AS_STRING(arg);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(arg)) {
|
else if (PyUnicode_Check(arg)) {
|
||||||
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
uarg = UNICODE_DEFAULT_ENCODING(arg);
|
||||||
if (uarg == NULL)
|
if (uarg == NULL)
|
||||||
|
@ -867,7 +858,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
arg, msgbuf, bufsize);
|
arg, msgbuf, bufsize);
|
||||||
*p = PyString_AS_STRING(uarg);
|
*p = PyString_AS_STRING(uarg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
return converterr("string or None",
|
return converterr("string or None",
|
||||||
arg, msgbuf, bufsize);
|
arg, msgbuf, bufsize);
|
||||||
|
@ -897,10 +887,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
|
|
||||||
/* Get 'e' parameter: the encoding name */
|
/* Get 'e' parameter: the encoding name */
|
||||||
encoding = (const char *)va_arg(*p_va, const char *);
|
encoding = (const char *)va_arg(*p_va, const char *);
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (encoding == NULL)
|
if (encoding == NULL)
|
||||||
encoding = PyUnicode_GetDefaultEncoding();
|
encoding = PyUnicode_GetDefaultEncoding();
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get output buffer parameter:
|
/* Get output buffer parameter:
|
||||||
's' (recode all objects via Unicode) or
|
's' (recode all objects via Unicode) or
|
||||||
|
@ -926,7 +914,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
Py_INCREF(s);
|
Py_INCREF(s);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
PyObject *u;
|
PyObject *u;
|
||||||
|
|
||||||
/* Convert object to Unicode */
|
/* Convert object to Unicode */
|
||||||
|
@ -950,9 +937,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
"(encoder failed to return a string)",
|
"(encoder failed to return a string)",
|
||||||
arg, msgbuf, bufsize);
|
arg, msgbuf, bufsize);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return converterr("string<e>", arg, msgbuf, bufsize);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
size = PyString_GET_SIZE(s);
|
size = PyString_GET_SIZE(s);
|
||||||
|
|
||||||
|
@ -1054,7 +1038,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'u': {/* raw unicode buffer (Py_UNICODE *) */
|
case 'u': {/* raw unicode buffer (Py_UNICODE *) */
|
||||||
if (*format == '#') { /* any buffer-like object */
|
if (*format == '#') { /* any buffer-like object */
|
||||||
void **p = (void **)va_arg(*p_va, char **);
|
void **p = (void **)va_arg(*p_va, char **);
|
||||||
|
@ -1077,7 +1060,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
case 'S': { /* string object */
|
case 'S': { /* string object */
|
||||||
PyObject **p = va_arg(*p_va, PyObject **);
|
PyObject **p = va_arg(*p_va, PyObject **);
|
||||||
|
@ -1088,7 +1070,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'U': { /* Unicode object */
|
case 'U': { /* Unicode object */
|
||||||
PyObject **p = va_arg(*p_va, PyObject **);
|
PyObject **p = va_arg(*p_va, PyObject **);
|
||||||
if (PyUnicode_Check(arg))
|
if (PyUnicode_Check(arg))
|
||||||
|
@ -1097,7 +1078,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
return converterr("unicode", arg, msgbuf, bufsize);
|
return converterr("unicode", arg, msgbuf, bufsize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
case 'O': { /* object */
|
case 'O': { /* object */
|
||||||
PyTypeObject *type;
|
PyTypeObject *type;
|
||||||
|
@ -1611,9 +1591,7 @@ skipitem(const char **p_format, va_list *p_va, int flags)
|
||||||
|
|
||||||
case 's': /* string */
|
case 's': /* string */
|
||||||
case 'z': /* string or None */
|
case 'z': /* string or None */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'u': /* unicode string */
|
case 'u': /* unicode string */
|
||||||
#endif
|
|
||||||
case 't': /* buffer, read-only */
|
case 't': /* buffer, read-only */
|
||||||
case 'w': /* buffer, read-write */
|
case 'w': /* buffer, read-write */
|
||||||
{
|
{
|
||||||
|
@ -1631,9 +1609,7 @@ skipitem(const char **p_format, va_list *p_va, int flags)
|
||||||
/* object codes */
|
/* object codes */
|
||||||
|
|
||||||
case 'S': /* string object */
|
case 'S': /* string object */
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'U': /* unicode string object */
|
case 'U': /* unicode string object */
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
(void) va_arg(*p_va, PyObject **);
|
(void) va_arg(*p_va, PyObject **);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1256,7 +1256,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
|
||||||
PyObject *v = PyList_GetItem(path, i);
|
PyObject *v = PyList_GetItem(path, i);
|
||||||
if (!v)
|
if (!v)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
if (PyUnicode_Check(v)) {
|
if (PyUnicode_Check(v)) {
|
||||||
copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v),
|
copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v),
|
||||||
PyUnicode_GET_SIZE(v), Py_FileSystemDefaultEncoding, NULL);
|
PyUnicode_GET_SIZE(v), Py_FileSystemDefaultEncoding, NULL);
|
||||||
|
@ -1265,7 +1264,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
|
||||||
v = copy;
|
v = copy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
if (!PyString_Check(v))
|
if (!PyString_Check(v))
|
||||||
continue;
|
continue;
|
||||||
len = PyString_GET_SIZE(v);
|
len = PyString_GET_SIZE(v);
|
||||||
|
|
|
@ -254,7 +254,6 @@ w_object(PyObject *v, WFILE *p)
|
||||||
w_long((long)n, p);
|
w_long((long)n, p);
|
||||||
w_string(PyString_AS_STRING(v), (int)n, p);
|
w_string(PyString_AS_STRING(v), (int)n, p);
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
else if (PyUnicode_Check(v)) {
|
else if (PyUnicode_Check(v)) {
|
||||||
PyObject *utf8;
|
PyObject *utf8;
|
||||||
utf8 = PyUnicode_AsUTF8String(v);
|
utf8 = PyUnicode_AsUTF8String(v);
|
||||||
|
@ -274,7 +273,6 @@ w_object(PyObject *v, WFILE *p)
|
||||||
w_string(PyString_AS_STRING(utf8), (int)n, p);
|
w_string(PyString_AS_STRING(utf8), (int)n, p);
|
||||||
Py_DECREF(utf8);
|
Py_DECREF(utf8);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (PyTuple_Check(v)) {
|
else if (PyTuple_Check(v)) {
|
||||||
w_byte(TYPE_TUPLE, p);
|
w_byte(TYPE_TUPLE, p);
|
||||||
n = PyTuple_Size(v);
|
n = PyTuple_Size(v);
|
||||||
|
@ -678,7 +676,6 @@ r_object(RFILE *p)
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case TYPE_UNICODE:
|
case TYPE_UNICODE:
|
||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
@ -701,7 +698,6 @@ r_object(RFILE *p)
|
||||||
PyMem_DEL(buffer);
|
PyMem_DEL(buffer);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
case TYPE_TUPLE:
|
case TYPE_TUPLE:
|
||||||
n = r_long(p);
|
n = r_long(p);
|
||||||
|
|
|
@ -240,7 +240,6 @@ do_mklist(const char **p_format, va_list *p_va, int endchar, int n, int flags)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
static int
|
static int
|
||||||
_ustrlen(Py_UNICODE *u)
|
_ustrlen(Py_UNICODE *u)
|
||||||
{
|
{
|
||||||
|
@ -249,7 +248,6 @@ _ustrlen(Py_UNICODE *u)
|
||||||
while (*v != 0) { i++; v++; }
|
while (*v != 0) { i++; v++; }
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
do_mktuple(const char **p_format, va_list *p_va, int endchar, int n, int flags)
|
do_mktuple(const char **p_format, va_list *p_va, int endchar, int n, int flags)
|
||||||
|
@ -349,7 +347,6 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
||||||
case 'K':
|
case 'K':
|
||||||
return PyLong_FromUnsignedLongLong((PY_LONG_LONG)va_arg(*p_va, unsigned PY_LONG_LONG));
|
return PyLong_FromUnsignedLongLong((PY_LONG_LONG)va_arg(*p_va, unsigned PY_LONG_LONG));
|
||||||
#endif
|
#endif
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
@ -375,7 +372,6 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'd':
|
case 'd':
|
||||||
return PyFloat_FromDouble(
|
return PyFloat_FromDouble(
|
||||||
|
|
|
@ -152,7 +152,7 @@ Py_InitializeEx(int install_sigs)
|
||||||
PyThreadState *tstate;
|
PyThreadState *tstate;
|
||||||
PyObject *bimod, *sysmod;
|
PyObject *bimod, *sysmod;
|
||||||
char *p;
|
char *p;
|
||||||
#if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET)
|
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
|
||||||
char *codeset;
|
char *codeset;
|
||||||
char *saved_locale;
|
char *saved_locale;
|
||||||
PyObject *sys_stream, *sys_isatty;
|
PyObject *sys_stream, *sys_isatty;
|
||||||
|
@ -199,10 +199,8 @@ Py_InitializeEx(int install_sigs)
|
||||||
if (interp->modules_reloading == NULL)
|
if (interp->modules_reloading == NULL)
|
||||||
Py_FatalError("Py_Initialize: can't make modules_reloading dictionary");
|
Py_FatalError("Py_Initialize: can't make modules_reloading dictionary");
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Init Unicode implementation; relies on the codec registry */
|
/* Init Unicode implementation; relies on the codec registry */
|
||||||
_PyUnicode_Init();
|
_PyUnicode_Init();
|
||||||
#endif
|
|
||||||
|
|
||||||
bimod = _PyBuiltin_Init();
|
bimod = _PyBuiltin_Init();
|
||||||
if (bimod == NULL)
|
if (bimod == NULL)
|
||||||
|
@ -250,7 +248,7 @@ Py_InitializeEx(int install_sigs)
|
||||||
if (!warnings_module)
|
if (!warnings_module)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
||||||
#if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET)
|
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
|
||||||
/* On Unix, set the file system encoding according to the
|
/* On Unix, set the file system encoding according to the
|
||||||
user's preference, if the CODESET names a well-known
|
user's preference, if the CODESET names a well-known
|
||||||
Python codec, and Py_FileSystemDefaultEncoding isn't
|
Python codec, and Py_FileSystemDefaultEncoding isn't
|
||||||
|
@ -468,10 +466,8 @@ Py_Finalize(void)
|
||||||
PyLong_Fini();
|
PyLong_Fini();
|
||||||
PyFloat_Fini();
|
PyFloat_Fini();
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
/* Cleanup Unicode implementation */
|
/* Cleanup Unicode implementation */
|
||||||
_PyUnicode_Fini();
|
_PyUnicode_Fini();
|
||||||
#endif
|
|
||||||
|
|
||||||
/* XXX Still allocated:
|
/* XXX Still allocated:
|
||||||
- various static ad-hoc pointers to interned strings
|
- various static ad-hoc pointers to interned strings
|
||||||
|
|
|
@ -210,7 +210,6 @@ If it is another kind of object, it will be printed and the system\n\
|
||||||
exit status will be one (i.e., failure)."
|
exit status will be one (i.e., failure)."
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_getdefaultencoding(PyObject *self)
|
sys_getdefaultencoding(PyObject *self)
|
||||||
|
@ -259,7 +258,6 @@ Return the encoding used to convert Unicode filenames in\n\
|
||||||
operating system filenames."
|
operating system filenames."
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -763,10 +761,8 @@ static PyMethodDef sys_methods[] = {
|
||||||
{"exc_clear", sys_exc_clear, METH_NOARGS, exc_clear_doc},
|
{"exc_clear", sys_exc_clear, METH_NOARGS, exc_clear_doc},
|
||||||
{"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc},
|
{"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc},
|
||||||
{"exit", sys_exit, METH_VARARGS, exit_doc},
|
{"exit", sys_exit, METH_VARARGS, exit_doc},
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"getdefaultencoding", (PyCFunction)sys_getdefaultencoding,
|
{"getdefaultencoding", (PyCFunction)sys_getdefaultencoding,
|
||||||
METH_NOARGS, getdefaultencoding_doc},
|
METH_NOARGS, getdefaultencoding_doc},
|
||||||
#endif
|
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
{"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS,
|
{"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS,
|
||||||
getdlopenflags_doc},
|
getdlopenflags_doc},
|
||||||
|
@ -777,10 +773,8 @@ static PyMethodDef sys_methods[] = {
|
||||||
#ifdef DYNAMIC_EXECUTION_PROFILE
|
#ifdef DYNAMIC_EXECUTION_PROFILE
|
||||||
{"getdxp", _Py_GetDXProfile, METH_VARARGS},
|
{"getdxp", _Py_GetDXProfile, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding,
|
{"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding,
|
||||||
METH_NOARGS, getfilesystemencoding_doc},
|
METH_NOARGS, getfilesystemencoding_doc},
|
||||||
#endif
|
|
||||||
#ifdef Py_TRACE_REFS
|
#ifdef Py_TRACE_REFS
|
||||||
{"getobjects", _Py_GetObjects, METH_VARARGS},
|
{"getobjects", _Py_GetObjects, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
|
@ -799,10 +793,8 @@ static PyMethodDef sys_methods[] = {
|
||||||
#ifdef USE_MALLOPT
|
#ifdef USE_MALLOPT
|
||||||
{"mdebug", sys_mdebug, METH_VARARGS},
|
{"mdebug", sys_mdebug, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
{"setdefaultencoding", sys_setdefaultencoding, METH_VARARGS,
|
{"setdefaultencoding", sys_setdefaultencoding, METH_VARARGS,
|
||||||
setdefaultencoding_doc},
|
setdefaultencoding_doc},
|
||||||
#endif
|
|
||||||
{"setcheckinterval", sys_setcheckinterval, METH_VARARGS,
|
{"setcheckinterval", sys_setcheckinterval, METH_VARARGS,
|
||||||
setcheckinterval_doc},
|
setcheckinterval_doc},
|
||||||
{"getcheckinterval", sys_getcheckinterval, METH_NOARGS,
|
{"getcheckinterval", sys_getcheckinterval, METH_NOARGS,
|
||||||
|
@ -1184,10 +1176,8 @@ _PySys_Init(void)
|
||||||
PyString_FromString(Py_GetExecPrefix()));
|
PyString_FromString(Py_GetExecPrefix()));
|
||||||
SET_SYS_FROM_STRING("maxint",
|
SET_SYS_FROM_STRING("maxint",
|
||||||
PyInt_FromLong(PyInt_GetMax()));
|
PyInt_FromLong(PyInt_GetMax()));
|
||||||
#ifdef Py_USING_UNICODE
|
|
||||||
SET_SYS_FROM_STRING("maxunicode",
|
SET_SYS_FROM_STRING("maxunicode",
|
||||||
PyInt_FromLong(PyUnicode_GetMax()));
|
PyInt_FromLong(PyUnicode_GetMax()));
|
||||||
#endif
|
|
||||||
SET_SYS_FROM_STRING("builtin_module_names",
|
SET_SYS_FROM_STRING("builtin_module_names",
|
||||||
list_builtin_module_names());
|
list_builtin_module_names());
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,9 +168,6 @@
|
||||||
/* This must be defined on some systems to enable large file support */
|
/* This must be defined on some systems to enable large file support */
|
||||||
#undef _LARGEFILE_SOURCE
|
#undef _LARGEFILE_SOURCE
|
||||||
|
|
||||||
/* Define if you want to have a Unicode type. */
|
|
||||||
#define Py_USING_UNICODE 1
|
|
||||||
|
|
||||||
/* Define as the integral type used for Unicode representation. */
|
/* Define as the integral type used for Unicode representation. */
|
||||||
#define PY_UNICODE_TYPE unsigned short
|
#define PY_UNICODE_TYPE unsigned short
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue