mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
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:
@@ -51,9 +51,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
|
||||
#ifdef Py_USING_UNICODE
|
||||
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.
|
||||
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_Str(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
|
||||
|
||||
@@ -26,7 +26,6 @@ typedef struct {
|
||||
PyObject *print_file_and_line;
|
||||
} PySyntaxErrorObject;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
@@ -38,7 +37,6 @@ typedef struct {
|
||||
PyObject *end;
|
||||
PyObject *reason;
|
||||
} PyUnicodeErrorObject;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
@@ -235,7 +233,6 @@ PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(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
|
||||
exceptions from C */
|
||||
|
||||
@@ -297,7 +294,6 @@ PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
|
||||
PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
||||
PyObject *, const char *);
|
||||
#endif
|
||||
|
||||
|
||||
/* 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 -------------------------------------------- */
|
||||
|
||||
#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
|
||||
properly set, but the default rules below doesn't set it. I'll
|
||||
sort this out some other day -- fredrik@pythonware.com */
|
||||
@@ -1262,5 +1255,4 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* Py_USING_UNICODE */
|
||||
#endif /* !Py_UNICODEOBJECT_H */
|
||||
|
||||
@@ -93,15 +93,8 @@ codec_encode(PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
|
||||
return NULL;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (encoding == NULL)
|
||||
encoding = PyUnicode_GetDefaultEncoding();
|
||||
#else
|
||||
if (encoding == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Encode via the codec registry */
|
||||
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))
|
||||
return NULL;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (encoding == NULL)
|
||||
encoding = PyUnicode_GetDefaultEncoding();
|
||||
#else
|
||||
if (encoding == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Decode via the codec registry */
|
||||
return PyCodec_Decode(v, encoding, errors);
|
||||
@@ -198,7 +184,6 @@ escape_encode(PyObject *self,
|
||||
return codec_tuple(str, PyString_Size(str));
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* --- Decoder ------------------------------------------------------------ */
|
||||
|
||||
static PyObject *
|
||||
@@ -833,7 +818,6 @@ mbcs_encode(PyObject *self,
|
||||
}
|
||||
|
||||
#endif /* MS_WINDOWS */
|
||||
#endif /* Py_USING_UNICODE */
|
||||
|
||||
/* --- Error handler registry --------------------------------------------- */
|
||||
|
||||
@@ -888,7 +872,6 @@ static PyMethodDef _codecs_functions[] = {
|
||||
decode__doc__},
|
||||
{"escape_encode", escape_encode, METH_VARARGS},
|
||||
{"escape_decode", escape_decode, METH_VARARGS},
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"utf_8_encode", utf_8_encode, METH_VARARGS},
|
||||
{"utf_8_decode", utf_8_decode, 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_decode", mbcs_decode, METH_VARARGS},
|
||||
#endif
|
||||
#endif /* Py_USING_UNICODE */
|
||||
{"register_error", register_error, METH_VARARGS,
|
||||
register_error__doc__},
|
||||
{"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
|
||||
#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
|
||||
that all use of text and tail as object pointers must be wrapped in
|
||||
JOIN_OBJ. see comments in the ElementObject definition for more
|
||||
@@ -724,7 +703,6 @@ checkpath(PyObject* tag)
|
||||
|
||||
#define PATHCHAR(ch) (ch == '/' || ch == '*' || ch == '[' || ch == '@')
|
||||
|
||||
#if defined(Py_USING_UNICODE)
|
||||
if (PyUnicode_Check(tag)) {
|
||||
Py_UNICODE *p = PyUnicode_AS_UNICODE(tag);
|
||||
for (i = 0; i < PyUnicode_GET_SIZE(tag); i++) {
|
||||
@@ -737,7 +715,6 @@ checkpath(PyObject* tag)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (PyString_Check(tag)) {
|
||||
char *p = PyString_AS_STRING(tag);
|
||||
for (i = 0; i < PyString_GET_SIZE(tag); i++) {
|
||||
@@ -1860,7 +1837,6 @@ static PyTypeObject XMLParser_Type;
|
||||
|
||||
/* helpers */
|
||||
|
||||
#if defined(Py_USING_UNICODE)
|
||||
LOCAL(int)
|
||||
checkstring(const char* string, int size)
|
||||
{
|
||||
@@ -1873,7 +1849,6 @@ checkstring(const char* string, int size)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
LOCAL(PyObject*)
|
||||
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
|
||||
Unicode string */
|
||||
|
||||
#if defined(Py_USING_UNICODE)
|
||||
if (checkstring(string, size))
|
||||
return PyUnicode_DecodeUTF8(string, size, "strict");
|
||||
#endif
|
||||
|
||||
return PyString_FromStringAndSize(string, size);
|
||||
}
|
||||
@@ -1934,7 +1907,6 @@ makeuniversal(XMLParserObject* self, const char* string)
|
||||
}
|
||||
|
||||
/* decode universal name */
|
||||
#if defined(Py_USING_UNICODE)
|
||||
/* inline makestring, to avoid duplicating the source string if
|
||||
it's not an utf-8 string */
|
||||
p = PyString_AS_STRING(tag);
|
||||
@@ -1946,7 +1918,6 @@ makeuniversal(XMLParserObject* self, const char* string)
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
value = tag; /* use tag as is */
|
||||
|
||||
/* 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
|
||||
expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
|
||||
XML_Encoding *info)
|
||||
@@ -2200,7 +2170,6 @@ expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
|
||||
|
||||
return XML_STATUS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* constructor and destructor */
|
||||
@@ -2306,12 +2275,10 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
|
||||
self->parser,
|
||||
(XML_ProcessingInstructionHandler) expat_pi_handler
|
||||
);
|
||||
#if defined(Py_USING_UNICODE)
|
||||
EXPAT(SetUnknownEncodingHandler)(
|
||||
self->parser,
|
||||
(XML_UnknownEncodingHandler) expat_unknown_encoding_handler, NULL
|
||||
);
|
||||
#endif
|
||||
|
||||
ALLOC(sizeof(XMLParserObject), "create expatparser");
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ PyDoc_STRVAR(strcoll__doc__,
|
||||
static PyObject*
|
||||
PyLocale_strcoll(PyObject* self, PyObject* args)
|
||||
{
|
||||
#if !defined(HAVE_WCSCOLL) || !defined(Py_USING_UNICODE)
|
||||
#if !defined(HAVE_WCSCOLL)
|
||||
char *s1,*s2;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss:strcoll", &s1, &s2))
|
||||
|
||||
@@ -58,12 +58,8 @@ static char copyright[] =
|
||||
/* defining this one enables tracing */
|
||||
#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) */
|
||||
#define HAVE_UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* optional features */
|
||||
|
||||
@@ -456,7 +456,6 @@ test_k_code(PyObject *self)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
||||
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
|
||||
of an error.
|
||||
@@ -518,7 +517,6 @@ codec_incrementaldecoder(PyObject *self, PyObject *args)
|
||||
return PyCodec_IncrementalDecoder(encoding, errors);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Simple test of _PyLong_NumBits and _PyLong_Sign. */
|
||||
static PyObject *
|
||||
@@ -863,9 +861,7 @@ static PyMethodDef TestMethods[] = {
|
||||
{"codec_incrementaldecoder",
|
||||
(PyCFunction)codec_incrementaldecoder, METH_VARARGS},
|
||||
#endif
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"test_u_code", (PyCFunction)test_u_code, METH_NOARGS},
|
||||
#endif
|
||||
#ifdef WITH_THREAD
|
||||
{"_test_thread_state", test_thread_state, METH_VARARGS},
|
||||
#endif
|
||||
|
||||
@@ -337,7 +337,6 @@ AsString(PyObject *value, PyObject *tmp)
|
||||
{
|
||||
if (PyString_Check(value))
|
||||
return PyString_AsString(value);
|
||||
#ifdef Py_USING_UNICODE
|
||||
else if (PyUnicode_Check(value)) {
|
||||
PyObject *v = PyUnicode_AsUTF8String(value);
|
||||
if (v == NULL)
|
||||
@@ -349,7 +348,6 @@ AsString(PyObject *value, PyObject *tmp)
|
||||
Py_DECREF(v);
|
||||
return PyString_AsString(v);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
PyObject *v = PyObject_Str(value);
|
||||
if (v == NULL)
|
||||
@@ -775,7 +773,6 @@ PyTclObject_string(PyTclObject *self, void *ignored)
|
||||
for (i = 0; i < len; i++)
|
||||
if (s[i] & 0x80)
|
||||
break;
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (i == len)
|
||||
/* It is an ASCII string. */
|
||||
self->string = PyString_FromStringAndSize(s, len);
|
||||
@@ -786,9 +783,6 @@ PyTclObject_string(PyTclObject *self, void *ignored)
|
||||
self->string = PyString_FromStringAndSize(s, len);
|
||||
}
|
||||
}
|
||||
#else
|
||||
self->string = PyString_FromStringAndSize(s, len);
|
||||
#endif
|
||||
if (!self->string)
|
||||
return NULL;
|
||||
}
|
||||
@@ -796,7 +790,6 @@ PyTclObject_string(PyTclObject *self, void *ignored)
|
||||
return self->string;
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyDoc_STRVAR(PyTclObject_unicode__doc__, "convert argument to unicode");
|
||||
|
||||
static PyObject *
|
||||
@@ -812,7 +805,6 @@ PyTclObject_unicode(PyTclObject *self, void *ignored)
|
||||
s = Tcl_GetStringFromObj(self->value, &len);
|
||||
return PyUnicode_DecodeUTF8(s, len, "strict");
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
PyTclObject_repr(PyTclObject *self)
|
||||
@@ -851,10 +843,8 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
|
||||
};
|
||||
|
||||
static PyMethodDef PyTclObject_methods[] = {
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS,
|
||||
PyTclObject_unicode__doc__},
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
|
||||
@@ -929,7 +919,6 @@ AsObj(PyObject *value)
|
||||
ckfree(FREECAST argv);
|
||||
return result;
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
else if (PyUnicode_Check(value)) {
|
||||
Py_UNICODE *inbuf = PyUnicode_AS_UNICODE(value);
|
||||
Py_ssize_t size = PyUnicode_GET_SIZE(value);
|
||||
@@ -962,7 +951,6 @@ AsObj(PyObject *value)
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
else if(PyTclObject_Check(value)) {
|
||||
Tcl_Obj *v = ((PyTclObject*)value)->value;
|
||||
Tcl_IncrRefCount(v);
|
||||
@@ -987,7 +975,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||
if (value->typePtr == NULL) {
|
||||
/* If the result contains any bytes with the top bit set,
|
||||
it's UTF-8 and we should decode it to Unicode */
|
||||
#ifdef Py_USING_UNICODE
|
||||
int i;
|
||||
char *s = value->bytes;
|
||||
int len = value->length;
|
||||
@@ -1006,9 +993,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||
result = PyString_FromStringAndSize(s, len);
|
||||
}
|
||||
}
|
||||
#else
|
||||
result = PyString_FromStringAndSize(value->bytes, value->length);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1066,7 +1050,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||
}
|
||||
|
||||
if (value->typePtr == app->StringType) {
|
||||
#ifdef Py_USING_UNICODE
|
||||
#if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX==3
|
||||
PyObject *result;
|
||||
int size;
|
||||
@@ -1085,12 +1068,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||
#else
|
||||
return PyUnicode_FromUnicode(Tcl_GetUnicode(value),
|
||||
Tcl_GetCharLength(value));
|
||||
#endif
|
||||
#else
|
||||
int size;
|
||||
char *c;
|
||||
c = Tcl_GetStringFromObj(value, &size);
|
||||
return PyString_FromStringAndSize(c, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1194,7 +1171,6 @@ Tkapp_CallResult(TkappObject *self)
|
||||
|
||||
/* If the result contains any bytes with the top bit set,
|
||||
it's UTF-8 and we should decode it to Unicode */
|
||||
#ifdef Py_USING_UNICODE
|
||||
while (*p != '\0') {
|
||||
if (*p & 0x80)
|
||||
break;
|
||||
@@ -1212,10 +1188,6 @@ Tkapp_CallResult(TkappObject *self)
|
||||
res = PyString_FromStringAndSize(s, (int)(p-s));
|
||||
}
|
||||
}
|
||||
#else
|
||||
p = strchr(p, '\0');
|
||||
res = PyString_FromStringAndSize(s, (int)(p-s));
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ BB_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
static PyObject *
|
||||
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];
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
h_getitem(arrayobject *ap, Py_ssize_t i)
|
||||
@@ -394,9 +392,7 @@ static struct arraydescr descriptors[] = {
|
||||
{'c', sizeof(char), c_getitem, c_setitem},
|
||||
{'b', sizeof(char), b_getitem, b_setitem},
|
||||
{'B', sizeof(char), BB_getitem, BB_setitem},
|
||||
#ifdef Py_USING_UNICODE
|
||||
{'u', sizeof(Py_UNICODE), u_getitem, u_setitem},
|
||||
#endif
|
||||
{'h', sizeof(short), h_getitem, h_setitem},
|
||||
{'H', sizeof(short), HH_getitem, HH_setitem},
|
||||
{'i', sizeof(int), i_getitem, i_setitem},
|
||||
@@ -1430,7 +1426,6 @@ representation.");
|
||||
|
||||
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
static PyObject *
|
||||
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\
|
||||
an array of some other type.");
|
||||
|
||||
#endif /* Py_USING_UNICODE */
|
||||
|
||||
|
||||
static PyObject *
|
||||
@@ -1536,10 +1530,8 @@ PyMethodDef array_methods[] = {
|
||||
fromlist_doc},
|
||||
{"fromstring", (PyCFunction)array_fromstring, METH_VARARGS,
|
||||
fromstring_doc},
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"fromunicode", (PyCFunction)array_fromunicode, METH_VARARGS,
|
||||
fromunicode_doc},
|
||||
#endif
|
||||
{"index", (PyCFunction)array_index, METH_O,
|
||||
index_doc},
|
||||
{"insert", (PyCFunction)array_insert, METH_VARARGS,
|
||||
@@ -1562,10 +1554,8 @@ PyMethodDef array_methods[] = {
|
||||
tolist_doc},
|
||||
{"tostring", (PyCFunction)array_tostring, METH_NOARGS,
|
||||
tostring_doc},
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"tounicode", (PyCFunction)array_tounicode, METH_NOARGS,
|
||||
tounicode_doc},
|
||||
#endif
|
||||
{"write", (PyCFunction)array_tofile, METH_O,
|
||||
tofile_doc},
|
||||
{NULL, NULL} /* sentinel */
|
||||
@@ -1587,10 +1577,8 @@ array_repr(arrayobject *a)
|
||||
|
||||
if (typecode == 'c')
|
||||
v = array_tostring(a, NULL);
|
||||
#ifdef Py_USING_UNICODE
|
||||
else if (typecode == 'u')
|
||||
v = array_tounicode(a, NULL);
|
||||
#endif
|
||||
else
|
||||
v = array_tolist(a, NULL);
|
||||
t = PyObject_Repr(v);
|
||||
@@ -1899,7 +1887,6 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(v);
|
||||
#ifdef Py_USING_UNICODE
|
||||
} else if (initial != NULL && PyUnicode_Check(initial)) {
|
||||
Py_ssize_t n = PyUnicode_GET_DATA_SIZE(initial);
|
||||
if (n > 0) {
|
||||
@@ -1916,7 +1903,6 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
memcpy(item, PyUnicode_AS_DATA(initial), n);
|
||||
self->allocated = self->ob_size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (it != NULL) {
|
||||
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
|
||||
backslash and newline characters to \uXXXX escapes. */
|
||||
static PyObject *
|
||||
@@ -1373,7 +1372,6 @@ save_unicode(Picklerobject *self, PyObject *args, int doput)
|
||||
Py_XDECREF(repr);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* A helper for save_tuple. Push the len elements in tuple t on the stack. */
|
||||
static int
|
||||
@@ -2225,13 +2223,11 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
||||
goto finally;
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
case 'u':
|
||||
if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
|
||||
res = save_unicode(self, args, 0);
|
||||
goto finally;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (args->ob_refcnt > 1) {
|
||||
@@ -2255,14 +2251,12 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
case 'u':
|
||||
if (type == &PyUnicode_Type) {
|
||||
res = save_unicode(self, args, 1);
|
||||
goto finally;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 't':
|
||||
if (type == &PyTuple_Type) {
|
||||
@@ -3326,7 +3320,6 @@ load_short_binstring(Unpicklerobject *self)
|
||||
}
|
||||
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
static int
|
||||
load_unicode(Unpicklerobject *self)
|
||||
{
|
||||
@@ -3346,10 +3339,8 @@ load_unicode(Unpicklerobject *self)
|
||||
finally:
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
static int
|
||||
load_binunicode(Unpicklerobject *self)
|
||||
{
|
||||
@@ -3370,7 +3361,6 @@ load_binunicode(Unpicklerobject *self)
|
||||
PDATA_PUSH(self->stack, unicode, -1);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
@@ -4347,7 +4337,6 @@ load(Unpicklerobject *self)
|
||||
break;
|
||||
continue;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
case UNICODE:
|
||||
if (load_unicode(self) < 0)
|
||||
break;
|
||||
@@ -4357,7 +4346,6 @@ load(Unpicklerobject *self)
|
||||
if (load_binunicode(self) < 0)
|
||||
break;
|
||||
continue;
|
||||
#endif
|
||||
|
||||
case EMPTY_TUPLE:
|
||||
if (load_counted_tuple(self, 0) < 0)
|
||||
@@ -4737,7 +4725,6 @@ noload(Unpicklerobject *self)
|
||||
break;
|
||||
continue;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
case UNICODE:
|
||||
if (load_unicode(self) < 0)
|
||||
break;
|
||||
@@ -4747,7 +4734,6 @@ noload(Unpicklerobject *self)
|
||||
if (load_binunicode(self) < 0)
|
||||
break;
|
||||
continue;
|
||||
#endif
|
||||
|
||||
case EMPTY_TUPLE:
|
||||
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\
|
||||
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)
|
||||
#define INCL_DOS
|
||||
@@ -1895,7 +1891,6 @@ posix_getcwd(PyObject *self, PyObject *noargs)
|
||||
return PyString_FromString(buf);
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyDoc_STRVAR(posix_getcwdu__doc__,
|
||||
"getcwdu() -> path\n\n\
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_LINK
|
||||
@@ -2242,7 +2236,6 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||
d = NULL;
|
||||
break;
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (arg_is_unicode) {
|
||||
PyObject *w;
|
||||
|
||||
@@ -2259,7 +2252,6 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (PyList_Append(d, v) != 0) {
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(d);
|
||||
@@ -5764,14 +5756,11 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||
char buf[MAXPATHLEN];
|
||||
char *path;
|
||||
int n;
|
||||
#ifdef Py_USING_UNICODE
|
||||
int arg_is_unicode = 0;
|
||||
#endif
|
||||
|
||||
if (!PyArg_ParseTuple(args, "et:readlink",
|
||||
Py_FileSystemDefaultEncoding, &path))
|
||||
return NULL;
|
||||
#ifdef Py_USING_UNICODE
|
||||
v = PySequence_GetItem(args, 0);
|
||||
if (v == NULL) return NULL;
|
||||
|
||||
@@ -5779,7 +5768,6 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||
arg_is_unicode = 1;
|
||||
}
|
||||
Py_DECREF(v);
|
||||
#endif
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
n = readlink(path, buf, (int) sizeof buf);
|
||||
@@ -5788,7 +5776,6 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||
return posix_error_with_filename(path);
|
||||
|
||||
v = PyString_FromStringAndSize(buf, n);
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (arg_is_unicode) {
|
||||
PyObject *w;
|
||||
|
||||
@@ -5805,7 +5792,6 @@ posix_readlink(PyObject *self, PyObject *args)
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
#endif /* HAVE_READLINK */
|
||||
@@ -8184,10 +8170,8 @@ static PyMethodDef posix_methods[] = {
|
||||
#endif
|
||||
#ifdef HAVE_GETCWD
|
||||
{"getcwd", posix_getcwd, METH_NOARGS, posix_getcwd__doc__},
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"getcwdu", posix_getcwdu, METH_NOARGS, posix_getcwdu__doc__},
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_LINK
|
||||
{"link", posix_link, METH_VARARGS, posix_link__doc__},
|
||||
#endif /* HAVE_LINK */
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
||||
#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
|
||||
#endif
|
||||
|
||||
enum HandlerTypes {
|
||||
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.
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert a string of XML_Chars into an 8-bit Python string.
|
||||
Returns None if str is a null pointer. */
|
||||
@@ -418,13 +411,9 @@ call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args,
|
||||
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 */
|
||||
#define STRING_CONV_FUNC (self->returns_unicode \
|
||||
? conv_string_to_unicode : conv_string_to_utf8)
|
||||
#endif
|
||||
|
||||
static PyObject*
|
||||
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);
|
||||
if (args == NULL)
|
||||
return -1;
|
||||
#ifdef Py_USING_UNICODE
|
||||
temp = (self->returns_unicode
|
||||
? conv_string_len_to_unicode(buffer, len)
|
||||
: conv_string_len_to_utf8(buffer, len));
|
||||
#else
|
||||
temp = conv_string_len_to_utf8(buffer, len);
|
||||
#endif
|
||||
if (temp == NULL) {
|
||||
Py_DECREF(args);
|
||||
flag_error(self);
|
||||
@@ -674,24 +659,6 @@ VOID_HANDLER(UnparsedEntityDecl,
|
||||
string_intern(self, systemId), string_intern(self, publicId),
|
||||
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 *userData,
|
||||
const XML_Char *entityName,
|
||||
@@ -710,7 +677,6 @@ VOID_HANDLER(EntityDecl,
|
||||
string_intern(self, base), string_intern(self, systemId),
|
||||
string_intern(self, publicId),
|
||||
string_intern(self, notationName)))
|
||||
#endif
|
||||
|
||||
VOID_HANDLER(XmlDecl,
|
||||
(void *userData,
|
||||
@@ -761,14 +727,10 @@ my_ElementDeclHandler(void *userData,
|
||||
|
||||
if (flush_character_buffer(self) < 0)
|
||||
goto finally;
|
||||
#ifdef Py_USING_UNICODE
|
||||
modelobj = conv_content_model(model,
|
||||
(self->returns_unicode
|
||||
? conv_string_to_unicode
|
||||
: conv_string_to_utf8));
|
||||
#else
|
||||
modelobj = conv_content_model(model, conv_string_to_utf8);
|
||||
#endif
|
||||
if (modelobj == NULL) {
|
||||
flag_error(self);
|
||||
goto finally;
|
||||
@@ -856,15 +818,6 @@ VOID_HANDLER(EndCdataSection,
|
||||
(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 *userData, const XML_Char *s, int len),
|
||||
("(N)", (self->returns_unicode
|
||||
@@ -876,7 +829,6 @@ VOID_HANDLER(DefaultHandlerExpand,
|
||||
("(N)", (self->returns_unicode
|
||||
? conv_string_len_to_unicode(s,len)
|
||||
: conv_string_len_to_utf8(s,len))))
|
||||
#endif
|
||||
|
||||
INT_HANDLER(NotStandalone,
|
||||
(void *userData),
|
||||
@@ -1268,7 +1220,6 @@ static struct PyMethodDef xmlparse_methods[] = {
|
||||
/* ---------- */
|
||||
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
||||
/* pyexpat international encoding support.
|
||||
Make it as simple as possible.
|
||||
@@ -1319,7 +1270,6 @@ PyUnknownEncodingHandler(void *encodingHandlerData,
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
||||
@@ -1336,11 +1286,7 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
||||
if (self == NULL)
|
||||
return NULL;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
self->returns_unicode = 1;
|
||||
#else
|
||||
self->returns_unicode = 0;
|
||||
#endif
|
||||
|
||||
self->buffer = NULL;
|
||||
self->buffer_size = CHARACTER_DATA_BUFFER_SIZE;
|
||||
@@ -1370,10 +1316,8 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
||||
return NULL;
|
||||
}
|
||||
XML_SetUserData(self->itself, (void *)self);
|
||||
#ifdef Py_USING_UNICODE
|
||||
XML_SetUnknownEncodingHandler(self->itself,
|
||||
(XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL);
|
||||
#endif
|
||||
|
||||
for (i = 0; handler_info[i].name != NULL; i++)
|
||||
/* do nothing */;
|
||||
@@ -1631,13 +1575,7 @@ xmlparse_setattr(xmlparseobject *self, char *name, PyObject *v)
|
||||
}
|
||||
if (strcmp(name, "returns_unicode") == 0) {
|
||||
if (PyObject_IsTrue(v)) {
|
||||
#ifndef Py_USING_UNICODE
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Unicode support not available");
|
||||
return -1;
|
||||
#else
|
||||
self->returns_unicode = 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
self->returns_unicode = 0;
|
||||
@@ -1886,9 +1824,7 @@ MODULE_INITFUNC(void)
|
||||
Py_BuildValue("(iii)", info.major,
|
||||
info.minor, info.micro));
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
init_template_buffer();
|
||||
#endif
|
||||
/* XXX When Expat supports some way of figuring out how it was
|
||||
compiled, this should check and set native_encoding
|
||||
appropriately.
|
||||
|
||||
@@ -931,13 +931,11 @@ PyNumber_Long(PyObject *o)
|
||||
*/
|
||||
return long_from_string(PyString_AS_STRING(o),
|
||||
PyString_GET_SIZE(o));
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (PyUnicode_Check(o))
|
||||
/* The above check is done in PyLong_FromUnicode(). */
|
||||
return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o),
|
||||
PyUnicode_GET_SIZE(o),
|
||||
10);
|
||||
#endif
|
||||
if (!PyObject_AsCharBuffer(o, &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 sign;
|
||||
char buffer[256]; /* For errors */
|
||||
#ifdef Py_USING_UNICODE
|
||||
char s_buffer[256];
|
||||
#endif
|
||||
Py_ssize_t len;
|
||||
|
||||
if (PyString_Check(v)) {
|
||||
s = PyString_AS_STRING(v);
|
||||
len = PyString_GET_SIZE(v);
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
else if (PyUnicode_Check(v)) {
|
||||
if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
@@ -720,7 +717,6 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
|
||||
s = s_buffer;
|
||||
len = strlen(s);
|
||||
}
|
||||
#endif
|
||||
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"complex() arg is not a string");
|
||||
|
||||
@@ -1183,7 +1183,6 @@ SimpleExtendsException(PyExc_StandardError, ValueError,
|
||||
SimpleExtendsException(PyExc_ValueError, UnicodeError,
|
||||
"Unicode related error.");
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
static int
|
||||
get_int(PyObject *attr, Py_ssize_t *value, const char *name)
|
||||
{
|
||||
@@ -1788,7 +1787,6 @@ PyUnicodeTranslateError_Create(
|
||||
return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns",
|
||||
object, length, start, end, reason);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -1989,11 +1987,9 @@ _PyExc_Init(void)
|
||||
PRE_INIT(KeyError)
|
||||
PRE_INIT(ValueError)
|
||||
PRE_INIT(UnicodeError)
|
||||
#ifdef Py_USING_UNICODE
|
||||
PRE_INIT(UnicodeEncodeError)
|
||||
PRE_INIT(UnicodeDecodeError)
|
||||
PRE_INIT(UnicodeTranslateError)
|
||||
#endif
|
||||
PRE_INIT(AssertionError)
|
||||
PRE_INIT(ArithmeticError)
|
||||
PRE_INIT(FloatingPointError)
|
||||
@@ -2051,11 +2047,9 @@ _PyExc_Init(void)
|
||||
POST_INIT(KeyError)
|
||||
POST_INIT(ValueError)
|
||||
POST_INIT(UnicodeError)
|
||||
#ifdef Py_USING_UNICODE
|
||||
POST_INIT(UnicodeEncodeError)
|
||||
POST_INIT(UnicodeDecodeError)
|
||||
POST_INIT(UnicodeTranslateError)
|
||||
#endif
|
||||
POST_INIT(AssertionError)
|
||||
POST_INIT(ArithmeticError)
|
||||
POST_INIT(FloatingPointError)
|
||||
|
||||
@@ -412,7 +412,6 @@ static PyObject *
|
||||
file_repr(PyFileObject *f)
|
||||
{
|
||||
if (PyUnicode_Check(f->f_name)) {
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyObject *ret = NULL;
|
||||
PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name);
|
||||
const char *name_str = name ? PyString_AsString(name) : "?";
|
||||
@@ -423,7 +422,6 @@ file_repr(PyFileObject *f)
|
||||
f);
|
||||
Py_XDECREF(name);
|
||||
return ret;
|
||||
#endif
|
||||
} else {
|
||||
return PyString_FromFormat("<%s file '%s', mode '%s' at %p>",
|
||||
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)) {
|
||||
Py_UNICODE *s = PyUnicode_AS_UNICODE(result);
|
||||
Py_ssize_t len = PyUnicode_GET_SIZE(result);
|
||||
@@ -1358,7 +1355,6 @@ PyFile_GetLine(PyObject *f, int n)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2124,15 +2120,12 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||
}
|
||||
else if (PyFile_Check(f)) {
|
||||
FILE *fp = PyFile_AsFile(f);
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyObject *enc = ((PyFileObject*)f)->f_encoding;
|
||||
int result;
|
||||
#endif
|
||||
if (fp == NULL) {
|
||||
err_closed();
|
||||
return -1;
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
if ((flags & Py_PRINT_RAW) &&
|
||||
PyUnicode_Check(v) && enc != Py_None) {
|
||||
char *cenc = PyString_AS_STRING(enc);
|
||||
@@ -2146,9 +2139,6 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||
result = PyObject_Print(value, fp, flags);
|
||||
Py_DECREF(value);
|
||||
return result;
|
||||
#else
|
||||
return PyObject_Print(v, fp, flags);
|
||||
#endif
|
||||
}
|
||||
writer = PyObject_GetAttrString(f, "write");
|
||||
if (writer == NULL)
|
||||
|
||||
@@ -68,16 +68,13 @@ PyFloat_FromString(PyObject *v)
|
||||
const char *s, *last, *end;
|
||||
double x;
|
||||
char buffer[256]; /* for errors */
|
||||
#ifdef Py_USING_UNICODE
|
||||
char s_buffer[256]; /* for objects convertible to a char buffer */
|
||||
#endif
|
||||
Py_ssize_t len;
|
||||
|
||||
if (PyString_Check(v)) {
|
||||
s = PyString_AS_STRING(v);
|
||||
len = PyString_GET_SIZE(v);
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
else if (PyUnicode_Check(v)) {
|
||||
if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
@@ -92,7 +89,6 @@ PyFloat_FromString(PyObject *v)
|
||||
s = s_buffer;
|
||||
len = strlen(s);
|
||||
}
|
||||
#endif
|
||||
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"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);
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyObject *
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Methods */
|
||||
|
||||
@@ -986,12 +984,10 @@ int_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
}
|
||||
return PyInt_FromString(string, NULL, base);
|
||||
}
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (PyUnicode_Check(x))
|
||||
return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x),
|
||||
PyUnicode_GET_SIZE(x),
|
||||
base);
|
||||
#endif
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"int() can't convert non-string with explicit base");
|
||||
return NULL;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user