mirror of https://github.com/python/cpython
Clean up a few tabs that went in with PEP393.
This commit is contained in:
parent
48a2f8fd97
commit
2aa2b3b4d5
|
@ -141,7 +141,7 @@ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
|
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
|
||||||
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
|
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
|
||||||
|
|
||||||
#include "pyfpe.h"
|
#include "pyfpe.h"
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,12 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||||
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
|
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define Py_RETURN_INF(sign) do \
|
#define Py_RETURN_INF(sign) do \
|
||||||
if (copysign(1., sign) == 1.) { \
|
if (copysign(1., sign) == 1.) { \
|
||||||
return PyFloat_FromDouble(Py_HUGE_VAL); \
|
return PyFloat_FromDouble(Py_HUGE_VAL); \
|
||||||
} else { \
|
} else { \
|
||||||
return PyFloat_FromDouble(-Py_HUGE_VAL); \
|
return PyFloat_FromDouble(-Py_HUGE_VAL); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
||||||
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
||||||
|
@ -113,9 +113,9 @@ PyAPI_FUNC(int) PyFloat_ClearFreeList(void);
|
||||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||||
(Advanced String Formatting). */
|
(Advanced String Formatting). */
|
||||||
PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
|
PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
|
||||||
PyObject *format_spec,
|
PyObject *format_spec,
|
||||||
Py_ssize_t start,
|
Py_ssize_t start,
|
||||||
Py_ssize_t end);
|
Py_ssize_t end);
|
||||||
#endif /* Py_LIMITED_API */
|
#endif /* Py_LIMITED_API */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -12,7 +12,7 @@ typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
|
||||||
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||||
|
|
||||||
#define PyLong_Check(op) \
|
#define PyLong_Check(op) \
|
||||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||||
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
|
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
||||||
|
@ -122,8 +122,8 @@ PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
|
||||||
enough memory to create the Python long.
|
enough memory to create the Python long.
|
||||||
*/
|
*/
|
||||||
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
||||||
const unsigned char* bytes, size_t n,
|
const unsigned char* bytes, size_t n,
|
||||||
int little_endian, int is_signed);
|
int little_endian, int is_signed);
|
||||||
|
|
||||||
/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
|
/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
|
||||||
v to a base-256 integer, stored in array bytes. Normally return 0,
|
v to a base-256 integer, stored in array bytes. Normally return 0,
|
||||||
|
@ -145,8 +145,8 @@ PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
||||||
case, but bytes holds the least-signficant n bytes of the true value.
|
case, but bytes holds the least-signficant n bytes of the true value.
|
||||||
*/
|
*/
|
||||||
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
|
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
|
||||||
unsigned char* bytes, size_t n,
|
unsigned char* bytes, size_t n,
|
||||||
int little_endian, int is_signed);
|
int little_endian, int is_signed);
|
||||||
|
|
||||||
|
|
||||||
/* _PyLong_Format: Convert the long to a string object with given base,
|
/* _PyLong_Format: Convert the long to a string object with given base,
|
||||||
|
@ -156,9 +156,9 @@ PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base);
|
||||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||||
(Advanced String Formatting). */
|
(Advanced String Formatting). */
|
||||||
PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
|
PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
|
||||||
PyObject *format_spec,
|
PyObject *format_spec,
|
||||||
Py_ssize_t start,
|
Py_ssize_t start,
|
||||||
Py_ssize_t end);
|
Py_ssize_t end);
|
||||||
#endif /* Py_LIMITED_API */
|
#endif /* Py_LIMITED_API */
|
||||||
|
|
||||||
/* These aren't really part of the long object, but they're handy. The
|
/* These aren't really part of the long object, but they're handy. The
|
||||||
|
|
226
Modules/_sre.c
226
Modules/_sre.c
|
@ -1739,16 +1739,16 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string,
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (logical_charsize == 1 && pattern->logical_charsize > 1) {
|
if (logical_charsize == 1 && pattern->logical_charsize > 1) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"can't use a string pattern on a bytes-like object");
|
"can't use a string pattern on a bytes-like object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (logical_charsize > 1 && pattern->logical_charsize == 1) {
|
if (logical_charsize > 1 && pattern->logical_charsize == 1) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"can't use a bytes pattern on a string-like object");
|
"can't use a bytes pattern on a string-like object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adjust boundaries */
|
/* adjust boundaries */
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
|
@ -2062,8 +2062,8 @@ pattern_findall(PatternObject* self, PyObject* args, PyObject* kw)
|
||||||
status = sre_usearch(&state, PatternObject_GetCode(self));
|
status = sre_usearch(&state, PatternObject_GetCode(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (status <= 0) {
|
if (status <= 0) {
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
|
@ -2190,8 +2190,8 @@ pattern_split(PatternObject* self, PyObject* args, PyObject* kw)
|
||||||
status = sre_usearch(&state, PatternObject_GetCode(self));
|
status = sre_usearch(&state, PatternObject_GetCode(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (status <= 0) {
|
if (status <= 0) {
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
|
@ -2334,8 +2334,8 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
|
||||||
status = sre_usearch(&state, PatternObject_GetCode(self));
|
status = sre_usearch(&state, PatternObject_GetCode(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (status <= 0) {
|
if (status <= 0) {
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
|
@ -2553,20 +2553,20 @@ PyDoc_STRVAR(pattern_doc, "Compiled regular expression objects");
|
||||||
|
|
||||||
static PyMethodDef pattern_methods[] = {
|
static PyMethodDef pattern_methods[] = {
|
||||||
{"match", (PyCFunction) pattern_match, METH_VARARGS|METH_KEYWORDS,
|
{"match", (PyCFunction) pattern_match, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_match_doc},
|
pattern_match_doc},
|
||||||
{"search", (PyCFunction) pattern_search, METH_VARARGS|METH_KEYWORDS,
|
{"search", (PyCFunction) pattern_search, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_search_doc},
|
pattern_search_doc},
|
||||||
{"sub", (PyCFunction) pattern_sub, METH_VARARGS|METH_KEYWORDS,
|
{"sub", (PyCFunction) pattern_sub, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_sub_doc},
|
pattern_sub_doc},
|
||||||
{"subn", (PyCFunction) pattern_subn, METH_VARARGS|METH_KEYWORDS,
|
{"subn", (PyCFunction) pattern_subn, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_subn_doc},
|
pattern_subn_doc},
|
||||||
{"split", (PyCFunction) pattern_split, METH_VARARGS|METH_KEYWORDS,
|
{"split", (PyCFunction) pattern_split, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_split_doc},
|
pattern_split_doc},
|
||||||
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
|
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_findall_doc},
|
pattern_findall_doc},
|
||||||
#if PY_VERSION_HEX >= 0x02020000
|
#if PY_VERSION_HEX >= 0x02020000
|
||||||
{"finditer", (PyCFunction) pattern_finditer, METH_VARARGS,
|
{"finditer", (PyCFunction) pattern_finditer, METH_VARARGS,
|
||||||
pattern_finditer_doc},
|
pattern_finditer_doc},
|
||||||
#endif
|
#endif
|
||||||
{"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
|
{"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
|
||||||
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
|
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
|
||||||
|
@ -2587,31 +2587,31 @@ static PyTypeObject Pattern_Type = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
"_" SRE_MODULE ".SRE_Pattern",
|
"_" SRE_MODULE ".SRE_Pattern",
|
||||||
sizeof(PatternObject), sizeof(SRE_CODE),
|
sizeof(PatternObject), sizeof(SRE_CODE),
|
||||||
(destructor)pattern_dealloc, /* tp_dealloc */
|
(destructor)pattern_dealloc, /* tp_dealloc */
|
||||||
0, /* tp_print */
|
0, /* tp_print */
|
||||||
0, /* tp_getattr */
|
0, /* tp_getattr */
|
||||||
0, /* tp_setattr */
|
0, /* tp_setattr */
|
||||||
0, /* tp_reserved */
|
0, /* tp_reserved */
|
||||||
0, /* tp_repr */
|
0, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
0, /* tp_hash */
|
0, /* tp_hash */
|
||||||
0, /* tp_call */
|
0, /* tp_call */
|
||||||
0, /* tp_str */
|
0, /* tp_str */
|
||||||
0, /* tp_getattro */
|
0, /* tp_getattro */
|
||||||
0, /* tp_setattro */
|
0, /* tp_setattro */
|
||||||
0, /* tp_as_buffer */
|
0, /* tp_as_buffer */
|
||||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||||
pattern_doc, /* tp_doc */
|
pattern_doc, /* tp_doc */
|
||||||
0, /* tp_traverse */
|
0, /* tp_traverse */
|
||||||
0, /* tp_clear */
|
0, /* tp_clear */
|
||||||
0, /* tp_richcompare */
|
0, /* tp_richcompare */
|
||||||
offsetof(PatternObject, weakreflist), /* tp_weaklistoffset */
|
offsetof(PatternObject, weakreflist), /* tp_weaklistoffset */
|
||||||
0, /* tp_iter */
|
0, /* tp_iter */
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
pattern_methods, /* tp_methods */
|
pattern_methods, /* tp_methods */
|
||||||
pattern_members, /* tp_members */
|
pattern_members, /* tp_members */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int _validate(PatternObject *self); /* Forward */
|
static int _validate(PatternObject *self); /* Forward */
|
||||||
|
@ -3210,8 +3210,8 @@ match_getindex(MatchObject* self, PyObject* index)
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
|
||||||
if (index == NULL)
|
if (index == NULL)
|
||||||
/* Default value */
|
/* Default value */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (PyLong_Check(index))
|
if (PyLong_Check(index))
|
||||||
return PyLong_AsSsize_t(index);
|
return PyLong_AsSsize_t(index);
|
||||||
|
@ -3551,7 +3551,7 @@ static PyObject *
|
||||||
match_lastindex_get(MatchObject *self)
|
match_lastindex_get(MatchObject *self)
|
||||||
{
|
{
|
||||||
if (self->lastindex >= 0)
|
if (self->lastindex >= 0)
|
||||||
return Py_BuildValue("i", self->lastindex);
|
return Py_BuildValue("i", self->lastindex);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
@ -3604,32 +3604,32 @@ static PyTypeObject Match_Type = {
|
||||||
PyVarObject_HEAD_INIT(NULL,0)
|
PyVarObject_HEAD_INIT(NULL,0)
|
||||||
"_" SRE_MODULE ".SRE_Match",
|
"_" SRE_MODULE ".SRE_Match",
|
||||||
sizeof(MatchObject), sizeof(Py_ssize_t),
|
sizeof(MatchObject), sizeof(Py_ssize_t),
|
||||||
(destructor)match_dealloc, /* tp_dealloc */
|
(destructor)match_dealloc, /* tp_dealloc */
|
||||||
0, /* tp_print */
|
0, /* tp_print */
|
||||||
0, /* tp_getattr */
|
0, /* tp_getattr */
|
||||||
0, /* tp_setattr */
|
0, /* tp_setattr */
|
||||||
0, /* tp_reserved */
|
0, /* tp_reserved */
|
||||||
0, /* tp_repr */
|
0, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
0, /* tp_hash */
|
0, /* tp_hash */
|
||||||
0, /* tp_call */
|
0, /* tp_call */
|
||||||
0, /* tp_str */
|
0, /* tp_str */
|
||||||
0, /* tp_getattro */
|
0, /* tp_getattro */
|
||||||
0, /* tp_setattro */
|
0, /* tp_setattro */
|
||||||
0, /* tp_as_buffer */
|
0, /* tp_as_buffer */
|
||||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||||
0, /* tp_doc */
|
0, /* tp_doc */
|
||||||
0, /* tp_traverse */
|
0, /* tp_traverse */
|
||||||
0, /* tp_clear */
|
0, /* tp_clear */
|
||||||
0, /* tp_richcompare */
|
0, /* tp_richcompare */
|
||||||
0, /* tp_weaklistoffset */
|
0, /* tp_weaklistoffset */
|
||||||
0, /* tp_iter */
|
0, /* tp_iter */
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
match_methods, /* tp_methods */
|
match_methods, /* tp_methods */
|
||||||
match_members, /* tp_members */
|
match_members, /* tp_members */
|
||||||
match_getset, /* tp_getset */
|
match_getset, /* tp_getset */
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
|
@ -3776,7 +3776,7 @@ static PyMethodDef scanner_methods[] = {
|
||||||
|
|
||||||
#define SCAN_OFF(x) offsetof(ScannerObject, x)
|
#define SCAN_OFF(x) offsetof(ScannerObject, x)
|
||||||
static PyMemberDef scanner_members[] = {
|
static PyMemberDef scanner_members[] = {
|
||||||
{"pattern", T_OBJECT, SCAN_OFF(pattern), READONLY},
|
{"pattern", T_OBJECT, SCAN_OFF(pattern), READONLY},
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3785,31 +3785,31 @@ static PyTypeObject Scanner_Type = {
|
||||||
"_" SRE_MODULE ".SRE_Scanner",
|
"_" SRE_MODULE ".SRE_Scanner",
|
||||||
sizeof(ScannerObject), 0,
|
sizeof(ScannerObject), 0,
|
||||||
(destructor)scanner_dealloc,/* tp_dealloc */
|
(destructor)scanner_dealloc,/* tp_dealloc */
|
||||||
0, /* tp_print */
|
0, /* tp_print */
|
||||||
0, /* tp_getattr */
|
0, /* tp_getattr */
|
||||||
0, /* tp_setattr */
|
0, /* tp_setattr */
|
||||||
0, /* tp_reserved */
|
0, /* tp_reserved */
|
||||||
0, /* tp_repr */
|
0, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
0, /* tp_hash */
|
0, /* tp_hash */
|
||||||
0, /* tp_call */
|
0, /* tp_call */
|
||||||
0, /* tp_str */
|
0, /* tp_str */
|
||||||
0, /* tp_getattro */
|
0, /* tp_getattro */
|
||||||
0, /* tp_setattro */
|
0, /* tp_setattro */
|
||||||
0, /* tp_as_buffer */
|
0, /* tp_as_buffer */
|
||||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||||
0, /* tp_doc */
|
0, /* tp_doc */
|
||||||
0, /* tp_traverse */
|
0, /* tp_traverse */
|
||||||
0, /* tp_clear */
|
0, /* tp_clear */
|
||||||
0, /* tp_richcompare */
|
0, /* tp_richcompare */
|
||||||
0, /* tp_weaklistoffset */
|
0, /* tp_weaklistoffset */
|
||||||
0, /* tp_iter */
|
0, /* tp_iter */
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
scanner_methods, /* tp_methods */
|
scanner_methods, /* tp_methods */
|
||||||
scanner_members, /* tp_members */
|
scanner_members, /* tp_members */
|
||||||
0, /* tp_getset */
|
0, /* tp_getset */
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
|
@ -3851,15 +3851,15 @@ static PyMethodDef _functions[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct PyModuleDef sremodule = {
|
static struct PyModuleDef sremodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
PyModuleDef_HEAD_INIT,
|
||||||
"_" SRE_MODULE,
|
"_" SRE_MODULE,
|
||||||
NULL,
|
NULL,
|
||||||
-1,
|
-1,
|
||||||
_functions,
|
_functions,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC PyInit__sre(void)
|
PyMODINIT_FUNC PyInit__sre(void)
|
||||||
|
@ -3875,7 +3875,7 @@ PyMODINIT_FUNC PyInit__sre(void)
|
||||||
|
|
||||||
m = PyModule_Create(&sremodule);
|
m = PyModule_Create(&sremodule);
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
x = PyLong_FromLong(SRE_MAGIC);
|
x = PyLong_FromLong(SRE_MAGIC);
|
||||||
|
|
|
@ -2345,21 +2345,21 @@ PyObject* PyType_FromSpec(PyType_Spec *spec)
|
||||||
return NULL;
|
return NULL;
|
||||||
res->ht_name = PyUnicode_FromString(spec->name);
|
res->ht_name = PyUnicode_FromString(spec->name);
|
||||||
if (!res->ht_name)
|
if (!res->ht_name)
|
||||||
goto fail;
|
goto fail;
|
||||||
res->ht_type.tp_name = _PyUnicode_AsString(res->ht_name);
|
res->ht_type.tp_name = _PyUnicode_AsString(res->ht_name);
|
||||||
if (!res->ht_type.tp_name)
|
if (!res->ht_type.tp_name)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
res->ht_type.tp_basicsize = spec->basicsize;
|
res->ht_type.tp_basicsize = spec->basicsize;
|
||||||
res->ht_type.tp_itemsize = spec->itemsize;
|
res->ht_type.tp_itemsize = spec->itemsize;
|
||||||
res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
|
res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
|
||||||
|
|
||||||
for (slot = spec->slots; slot->slot; slot++) {
|
for (slot = spec->slots; slot->slot; slot++) {
|
||||||
if (slot->slot >= sizeof(slotoffsets)/sizeof(slotoffsets[0])) {
|
if (slot->slot >= sizeof(slotoffsets)/sizeof(slotoffsets[0])) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
|
PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
*(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc;
|
*(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc;
|
||||||
|
|
||||||
/* need to make a copy of the docstring slot, which usually
|
/* need to make a copy of the docstring slot, which usually
|
||||||
points to a static string literal */
|
points to a static string literal */
|
||||||
|
@ -2367,7 +2367,7 @@ PyObject* PyType_FromSpec(PyType_Spec *spec)
|
||||||
ssize_t len = strlen(slot->pfunc)+1;
|
ssize_t len = strlen(slot->pfunc)+1;
|
||||||
char *tp_doc = PyObject_MALLOC(len);
|
char *tp_doc = PyObject_MALLOC(len);
|
||||||
if (tp_doc == NULL)
|
if (tp_doc == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
memcpy(tp_doc, slot->pfunc, len);
|
memcpy(tp_doc, slot->pfunc, len);
|
||||||
res->ht_type.tp_doc = tp_doc;
|
res->ht_type.tp_doc = tp_doc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,10 +174,10 @@ unicode_encode_call_errorhandler(const char *errors,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
raise_encode_exception(PyObject **exceptionObject,
|
raise_encode_exception(PyObject **exceptionObject,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const Py_UNICODE *unicode, Py_ssize_t size,
|
const Py_UNICODE *unicode, Py_ssize_t size,
|
||||||
Py_ssize_t startpos, Py_ssize_t endpos,
|
Py_ssize_t startpos, Py_ssize_t endpos,
|
||||||
const char *reason);
|
const char *reason);
|
||||||
|
|
||||||
/* Same for linebreaks */
|
/* Same for linebreaks */
|
||||||
static unsigned char ascii_linebreak[] = {
|
static unsigned char ascii_linebreak[] = {
|
||||||
|
@ -2035,8 +2035,8 @@ PyUnicode_FromObject(register PyObject *obj)
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_FromEncodedObject(register PyObject *obj,
|
PyUnicode_FromEncodedObject(register PyObject *obj,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
Py_buffer buffer;
|
Py_buffer buffer;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
@ -2121,9 +2121,9 @@ normalize_encoding(const char *encoding,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_Decode(const char *s,
|
PyUnicode_Decode(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *buffer = NULL, *unicode;
|
PyObject *buffer = NULL, *unicode;
|
||||||
Py_buffer info;
|
Py_buffer info;
|
||||||
|
@ -2184,8 +2184,8 @@ PyUnicode_Decode(const char *s,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_AsDecodedObject(PyObject *unicode,
|
PyUnicode_AsDecodedObject(PyObject *unicode,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
|
||||||
|
@ -2209,8 +2209,8 @@ PyUnicode_AsDecodedObject(PyObject *unicode,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_AsDecodedUnicode(PyObject *unicode,
|
PyUnicode_AsDecodedUnicode(PyObject *unicode,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
|
||||||
|
@ -2241,9 +2241,9 @@ PyUnicode_AsDecodedUnicode(PyObject *unicode,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_Encode(const Py_UNICODE *s,
|
PyUnicode_Encode(const Py_UNICODE *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v, *unicode;
|
PyObject *v, *unicode;
|
||||||
|
|
||||||
|
@ -2257,8 +2257,8 @@ PyUnicode_Encode(const Py_UNICODE *s,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_AsEncodedObject(PyObject *unicode,
|
PyUnicode_AsEncodedObject(PyObject *unicode,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
|
||||||
|
@ -2345,8 +2345,8 @@ PyUnicode_EncodeFSDefault(PyObject *unicode)
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_AsEncodedString(PyObject *unicode,
|
PyUnicode_AsEncodedString(PyObject *unicode,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
char lower[11]; /* Enough for any encoding shortcut */
|
char lower[11]; /* Enough for any encoding shortcut */
|
||||||
|
@ -2423,8 +2423,8 @@ PyUnicode_AsEncodedString(PyObject *unicode,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_AsEncodedUnicode(PyObject *unicode,
|
PyUnicode_AsEncodedUnicode(PyObject *unicode,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
|
||||||
|
@ -2841,10 +2841,10 @@ onError:
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler,
|
unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler,
|
||||||
const char *encoding, const char *reason,
|
const char *encoding, const char *reason,
|
||||||
const char **input, const char **inend, Py_ssize_t *startinpos,
|
const char **input, const char **inend, Py_ssize_t *startinpos,
|
||||||
Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
|
Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
|
||||||
PyUnicodeObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr)
|
PyUnicodeObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr)
|
||||||
{
|
{
|
||||||
static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
|
static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
|
||||||
|
|
||||||
|
@ -3016,8 +3016,8 @@ char utf7_category[128] = {
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_DecodeUTF7(const char *s,
|
PyUnicode_DecodeUTF7(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
return PyUnicode_DecodeUTF7Stateful(s, size, errors, NULL);
|
return PyUnicode_DecodeUTF7Stateful(s, size, errors, NULL);
|
||||||
}
|
}
|
||||||
|
@ -3031,9 +3031,9 @@ PyUnicode_DecodeUTF7(const char *s,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_DecodeUTF7Stateful(const char *s,
|
PyUnicode_DecodeUTF7Stateful(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors,
|
const char *errors,
|
||||||
Py_ssize_t *consumed)
|
Py_ssize_t *consumed)
|
||||||
{
|
{
|
||||||
const char *starts = s;
|
const char *starts = s;
|
||||||
Py_ssize_t startinpos;
|
Py_ssize_t startinpos;
|
||||||
|
@ -3226,10 +3226,10 @@ utf7Error:
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_EncodeUTF7(const Py_UNICODE *s,
|
PyUnicode_EncodeUTF7(const Py_UNICODE *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
int base64SetO,
|
int base64SetO,
|
||||||
int base64WhiteSpace,
|
int base64WhiteSpace,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
/* It might be possible to tighten this worst case */
|
/* It might be possible to tighten this worst case */
|
||||||
|
@ -3352,8 +3352,8 @@ char utf8_code_length[256] = {
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_DecodeUTF8(const char *s,
|
PyUnicode_DecodeUTF8(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
|
return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
|
||||||
}
|
}
|
||||||
|
@ -4868,8 +4868,8 @@ static _PyUnicode_Name_CAPI *ucnhash_CAPI = NULL;
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_DecodeUnicodeEscape(const char *s,
|
PyUnicode_DecodeUnicodeEscape(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
const char *starts = s;
|
const char *starts = s;
|
||||||
Py_ssize_t startinpos;
|
Py_ssize_t startinpos;
|
||||||
|
@ -5172,7 +5172,7 @@ static const char *hexdigits = "0123456789abcdef";
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s,
|
PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s,
|
||||||
Py_ssize_t size)
|
Py_ssize_t size)
|
||||||
{
|
{
|
||||||
PyObject *repr;
|
PyObject *repr;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -5329,8 +5329,8 @@ PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_DecodeRawUnicodeEscape(const char *s,
|
PyUnicode_DecodeRawUnicodeEscape(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
const char *starts = s;
|
const char *starts = s;
|
||||||
Py_ssize_t startinpos;
|
Py_ssize_t startinpos;
|
||||||
|
@ -5451,7 +5451,7 @@ PyUnicode_DecodeRawUnicodeEscape(const char *s,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s,
|
PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s,
|
||||||
Py_ssize_t size)
|
Py_ssize_t size)
|
||||||
{
|
{
|
||||||
PyObject *repr;
|
PyObject *repr;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -5556,8 +5556,8 @@ PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyUnicode_DecodeUnicodeInternal(const char *s,
|
_PyUnicode_DecodeUnicodeInternal(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
const char *starts = s;
|
const char *starts = s;
|
||||||
Py_ssize_t startinpos;
|
Py_ssize_t startinpos;
|
||||||
|
@ -5641,8 +5641,8 @@ _PyUnicode_DecodeUnicodeInternal(const char *s,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_DecodeLatin1(const char *s,
|
PyUnicode_DecodeLatin1(const char *s,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
/* Latin-1 is equivalent to the first 256 ordinals in Unicode. */
|
/* Latin-1 is equivalent to the first 256 ordinals in Unicode. */
|
||||||
return _PyUnicode_FromUCS1((unsigned char*)s, size);
|
return _PyUnicode_FromUCS1((unsigned char*)s, size);
|
||||||
|
@ -5651,10 +5651,10 @@ PyUnicode_DecodeLatin1(const char *s,
|
||||||
/* create or adjust a UnicodeEncodeError */
|
/* create or adjust a UnicodeEncodeError */
|
||||||
static void
|
static void
|
||||||
make_encode_exception(PyObject **exceptionObject,
|
make_encode_exception(PyObject **exceptionObject,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const Py_UNICODE *unicode, Py_ssize_t size,
|
const Py_UNICODE *unicode, Py_ssize_t size,
|
||||||
Py_ssize_t startpos, Py_ssize_t endpos,
|
Py_ssize_t startpos, Py_ssize_t endpos,
|
||||||
const char *reason)
|
const char *reason)
|
||||||
{
|
{
|
||||||
if (*exceptionObject == NULL) {
|
if (*exceptionObject == NULL) {
|
||||||
*exceptionObject = PyUnicodeEncodeError_Create(
|
*exceptionObject = PyUnicodeEncodeError_Create(
|
||||||
|
@ -5677,10 +5677,10 @@ make_encode_exception(PyObject **exceptionObject,
|
||||||
/* raises a UnicodeEncodeError */
|
/* raises a UnicodeEncodeError */
|
||||||
static void
|
static void
|
||||||
raise_encode_exception(PyObject **exceptionObject,
|
raise_encode_exception(PyObject **exceptionObject,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
const Py_UNICODE *unicode, Py_ssize_t size,
|
const Py_UNICODE *unicode, Py_ssize_t size,
|
||||||
Py_ssize_t startpos, Py_ssize_t endpos,
|
Py_ssize_t startpos, Py_ssize_t endpos,
|
||||||
const char *reason)
|
const char *reason)
|
||||||
{
|
{
|
||||||
make_encode_exception(exceptionObject,
|
make_encode_exception(exceptionObject,
|
||||||
encoding, unicode, size, startpos, endpos, reason);
|
encoding, unicode, size, startpos, endpos, reason);
|
||||||
|
@ -5694,11 +5694,11 @@ raise_encode_exception(PyObject **exceptionObject,
|
||||||
has to be freed by the caller */
|
has to be freed by the caller */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicode_encode_call_errorhandler(const char *errors,
|
unicode_encode_call_errorhandler(const char *errors,
|
||||||
PyObject **errorHandler,
|
PyObject **errorHandler,
|
||||||
const char *encoding, const char *reason,
|
const char *encoding, const char *reason,
|
||||||
const Py_UNICODE *unicode, Py_ssize_t size, PyObject **exceptionObject,
|
const Py_UNICODE *unicode, Py_ssize_t size, PyObject **exceptionObject,
|
||||||
Py_ssize_t startpos, Py_ssize_t endpos,
|
Py_ssize_t startpos, Py_ssize_t endpos,
|
||||||
Py_ssize_t *newpos)
|
Py_ssize_t *newpos)
|
||||||
{
|
{
|
||||||
static char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
|
static char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
|
||||||
|
|
||||||
|
@ -5749,9 +5749,9 @@ unicode_encode_call_errorhandler(const char *errors,
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicode_encode_ucs1(const Py_UNICODE *p,
|
unicode_encode_ucs1(const Py_UNICODE *p,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors,
|
const char *errors,
|
||||||
int limit)
|
int limit)
|
||||||
{
|
{
|
||||||
/* output object */
|
/* output object */
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
|
@ -5946,8 +5946,8 @@ unicode_encode_ucs1(const Py_UNICODE *p,
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyUnicode_EncodeLatin1(const Py_UNICODE *p,
|
PyUnicode_EncodeLatin1(const Py_UNICODE *p,
|
||||||
Py_ssize_t size,
|
Py_ssize_t size,
|
||||||
const char *errors)
|
const char *errors)
|
||||||
{
|
{
|
||||||
return unicode_encode_ucs1(p, size, errors, 256);
|
return unicode_encode_ucs1(p, size, errors, 256);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue