mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
More low-hanging fruit. Still need to re-arrange some code (or find a better
solution) in the same way as listobject.c got changed. Hoping for a better solution.
This commit is contained in:
parent
1cf3964fd1
commit
a62862120d
5 changed files with 80 additions and 79 deletions
|
|
@ -529,7 +529,7 @@ new_arena(void)
|
||||||
nbytes = numarenas * sizeof(*arenas);
|
nbytes = numarenas * sizeof(*arenas);
|
||||||
if (nbytes / sizeof(*arenas) != numarenas)
|
if (nbytes / sizeof(*arenas) != numarenas)
|
||||||
return NULL; /* overflow */
|
return NULL; /* overflow */
|
||||||
arenaobj = realloc(arenas, nbytes);
|
arenaobj = (arena_object *)realloc(arenas, nbytes);
|
||||||
if (arenaobj == NULL)
|
if (arenaobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
arenas = arenaobj;
|
arenas = arenaobj;
|
||||||
|
|
|
||||||
|
|
@ -1051,7 +1051,7 @@ string_contains(PyObject *a, PyObject *el)
|
||||||
lastchar = sub[shortsub];
|
lastchar = sub[shortsub];
|
||||||
last = s + PyString_GET_SIZE(a) - len_sub + 1;
|
last = s + PyString_GET_SIZE(a) - len_sub + 1;
|
||||||
while (s < last) {
|
while (s < last) {
|
||||||
s = memchr(s, firstchar, last-s);
|
s = (char *)memchr(s, firstchar, last-s);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
assert(s < last);
|
assert(s < last);
|
||||||
|
|
@ -1210,7 +1210,7 @@ string_subscript(PyStringObject* self, PyObject* item)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
source_buf = PyString_AsString((PyObject*)self);
|
source_buf = PyString_AsString((PyObject*)self);
|
||||||
result_buf = PyMem_Malloc(slicelength);
|
result_buf = (char *)PyMem_Malloc(slicelength);
|
||||||
if (result_buf == NULL)
|
if (result_buf == NULL)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
||||||
|
|
@ -2028,12 +2028,12 @@ string_lower(PyStringObject *self)
|
||||||
{
|
{
|
||||||
char *s = PyString_AS_STRING(self), *s_new;
|
char *s = PyString_AS_STRING(self), *s_new;
|
||||||
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
||||||
PyObject *new;
|
PyObject *newobj;
|
||||||
|
|
||||||
new = PyString_FromStringAndSize(NULL, n);
|
newobj = PyString_FromStringAndSize(NULL, n);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
s_new = PyString_AsString(new);
|
s_new = PyString_AsString(newobj);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
int c = Py_CHARMASK(*s++);
|
int c = Py_CHARMASK(*s++);
|
||||||
if (isupper(c)) {
|
if (isupper(c)) {
|
||||||
|
|
@ -2042,7 +2042,7 @@ string_lower(PyStringObject *self)
|
||||||
*s_new = c;
|
*s_new = c;
|
||||||
s_new++;
|
s_new++;
|
||||||
}
|
}
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2056,12 +2056,12 @@ string_upper(PyStringObject *self)
|
||||||
{
|
{
|
||||||
char *s = PyString_AS_STRING(self), *s_new;
|
char *s = PyString_AS_STRING(self), *s_new;
|
||||||
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
||||||
PyObject *new;
|
PyObject *newobj;
|
||||||
|
|
||||||
new = PyString_FromStringAndSize(NULL, n);
|
newobj = PyString_FromStringAndSize(NULL, n);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
s_new = PyString_AsString(new);
|
s_new = PyString_AsString(newobj);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
int c = Py_CHARMASK(*s++);
|
int c = Py_CHARMASK(*s++);
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
|
|
@ -2070,7 +2070,7 @@ string_upper(PyStringObject *self)
|
||||||
*s_new = c;
|
*s_new = c;
|
||||||
s_new++;
|
s_new++;
|
||||||
}
|
}
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2086,12 +2086,12 @@ string_title(PyStringObject *self)
|
||||||
char *s = PyString_AS_STRING(self), *s_new;
|
char *s = PyString_AS_STRING(self), *s_new;
|
||||||
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
||||||
int previous_is_cased = 0;
|
int previous_is_cased = 0;
|
||||||
PyObject *new;
|
PyObject *newobj;
|
||||||
|
|
||||||
new = PyString_FromStringAndSize(NULL, n);
|
newobj = PyString_FromStringAndSize(NULL, n);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
s_new = PyString_AsString(new);
|
s_new = PyString_AsString(newobj);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
int c = Py_CHARMASK(*s++);
|
int c = Py_CHARMASK(*s++);
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
|
|
@ -2106,7 +2106,7 @@ string_title(PyStringObject *self)
|
||||||
previous_is_cased = 0;
|
previous_is_cased = 0;
|
||||||
*s_new++ = c;
|
*s_new++ = c;
|
||||||
}
|
}
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(capitalize__doc__,
|
PyDoc_STRVAR(capitalize__doc__,
|
||||||
|
|
@ -2120,12 +2120,12 @@ string_capitalize(PyStringObject *self)
|
||||||
{
|
{
|
||||||
char *s = PyString_AS_STRING(self), *s_new;
|
char *s = PyString_AS_STRING(self), *s_new;
|
||||||
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
||||||
PyObject *new;
|
PyObject *newobj;
|
||||||
|
|
||||||
new = PyString_FromStringAndSize(NULL, n);
|
newobj = PyString_FromStringAndSize(NULL, n);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
s_new = PyString_AsString(new);
|
s_new = PyString_AsString(newobj);
|
||||||
if (0 < n) {
|
if (0 < n) {
|
||||||
int c = Py_CHARMASK(*s++);
|
int c = Py_CHARMASK(*s++);
|
||||||
if (islower(c))
|
if (islower(c))
|
||||||
|
|
@ -2142,7 +2142,7 @@ string_capitalize(PyStringObject *self)
|
||||||
*s_new = c;
|
*s_new = c;
|
||||||
s_new++;
|
s_new++;
|
||||||
}
|
}
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2199,7 +2199,7 @@ string_count(PyStringObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
if (i >= m)
|
if (i >= m)
|
||||||
break;
|
break;
|
||||||
t = memchr(s+i, sub[0], m-i);
|
t = (const char *)memchr(s+i, sub[0], m-i);
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
break;
|
break;
|
||||||
i = t - s;
|
i = t - s;
|
||||||
|
|
@ -2218,12 +2218,12 @@ string_swapcase(PyStringObject *self)
|
||||||
{
|
{
|
||||||
char *s = PyString_AS_STRING(self), *s_new;
|
char *s = PyString_AS_STRING(self), *s_new;
|
||||||
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
Py_ssize_t i, n = PyString_GET_SIZE(self);
|
||||||
PyObject *new;
|
PyObject *newobj;
|
||||||
|
|
||||||
new = PyString_FromStringAndSize(NULL, n);
|
newobj = PyString_FromStringAndSize(NULL, n);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
s_new = PyString_AsString(new);
|
s_new = PyString_AsString(newobj);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
int c = Py_CHARMASK(*s++);
|
int c = Py_CHARMASK(*s++);
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
|
|
@ -2236,7 +2236,7 @@ string_swapcase(PyStringObject *self)
|
||||||
*s_new = c;
|
*s_new = c;
|
||||||
s_new++;
|
s_new++;
|
||||||
}
|
}
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2524,7 +2524,7 @@ string_replace(PyStringObject *self, PyObject *args)
|
||||||
const Py_ssize_t len = PyString_GET_SIZE(self);
|
const Py_ssize_t len = PyString_GET_SIZE(self);
|
||||||
Py_ssize_t sub_len, repl_len, out_len;
|
Py_ssize_t sub_len, repl_len, out_len;
|
||||||
int count = -1;
|
int count = -1;
|
||||||
PyObject *new;
|
PyObject *newobj;
|
||||||
PyObject *subobj, *replobj;
|
PyObject *subobj, *replobj;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "OO|i:replace",
|
if (!PyArg_ParseTuple(args, "OO|i:replace",
|
||||||
|
|
@ -2563,20 +2563,20 @@ string_replace(PyStringObject *self, PyObject *args)
|
||||||
if (out_len == -1) {
|
if (out_len == -1) {
|
||||||
if (PyString_CheckExact(self)) {
|
if (PyString_CheckExact(self)) {
|
||||||
/* we're returning another reference to self */
|
/* we're returning another reference to self */
|
||||||
new = (PyObject*)self;
|
newobj = (PyObject*)self;
|
||||||
Py_INCREF(new);
|
Py_INCREF(newobj);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new = PyString_FromStringAndSize(str, len);
|
newobj = PyString_FromStringAndSize(str, len);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new = PyString_FromStringAndSize(new_s, out_len);
|
newobj = PyString_FromStringAndSize(new_s, out_len);
|
||||||
PyMem_FREE(new_s);
|
PyMem_FREE(new_s);
|
||||||
}
|
}
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -547,7 +547,7 @@ tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
PyObject *tmp, *new, *item;
|
PyObject *tmp, *newobj, *item;
|
||||||
Py_ssize_t i, n;
|
Py_ssize_t i, n;
|
||||||
|
|
||||||
assert(PyType_IsSubtype(type, &PyTuple_Type));
|
assert(PyType_IsSubtype(type, &PyTuple_Type));
|
||||||
|
|
@ -555,16 +555,16 @@ tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
assert(PyTuple_Check(tmp));
|
assert(PyTuple_Check(tmp));
|
||||||
new = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
|
newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
item = PyTuple_GET_ITEM(tmp, i);
|
item = PyTuple_GET_ITEM(tmp, i);
|
||||||
Py_INCREF(item);
|
Py_INCREF(item);
|
||||||
PyTuple_SET_ITEM(new, i, item);
|
PyTuple_SET_ITEM(newobj, i, item);
|
||||||
}
|
}
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
return new;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(tuple_doc,
|
PyDoc_STRVAR(tuple_doc,
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
|
||||||
if (PyType_IS_GC(type))
|
if (PyType_IS_GC(type))
|
||||||
obj = _PyObject_GC_Malloc(size);
|
obj = _PyObject_GC_Malloc(size);
|
||||||
else
|
else
|
||||||
obj = PyObject_MALLOC(size);
|
obj = (PyObject *)PyObject_MALLOC(size);
|
||||||
|
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
@ -1150,7 +1150,7 @@ pmerge(PyObject *acc, PyObject* to_merge) {
|
||||||
remain[i] is the index of the next base in to_merge[i]
|
remain[i] is the index of the next base in to_merge[i]
|
||||||
that is not included in acc.
|
that is not included in acc.
|
||||||
*/
|
*/
|
||||||
remain = PyMem_MALLOC(SIZEOF_INT*to_merge_size);
|
remain = (int *)PyMem_MALLOC(SIZEOF_INT*to_merge_size);
|
||||||
if (remain == NULL)
|
if (remain == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
for (i = 0; i < to_merge_size; i++)
|
for (i = 0; i < to_merge_size; i++)
|
||||||
|
|
@ -1896,7 +1896,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
PyObject *doc = PyDict_GetItemString(dict, "__doc__");
|
PyObject *doc = PyDict_GetItemString(dict, "__doc__");
|
||||||
if (doc != NULL && PyString_Check(doc)) {
|
if (doc != NULL && PyString_Check(doc)) {
|
||||||
const size_t n = (size_t)PyString_GET_SIZE(doc);
|
const size_t n = (size_t)PyString_GET_SIZE(doc);
|
||||||
char *tp_doc = PyObject_MALLOC(n+1);
|
char *tp_doc = (char *)PyObject_MALLOC(n+1);
|
||||||
if (tp_doc == NULL) {
|
if (tp_doc == NULL) {
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -2446,23 +2446,23 @@ same_slots_added(PyTypeObject *a, PyTypeObject *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
compatible_for_assignment(PyTypeObject* old, PyTypeObject* new, char* attr)
|
compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr)
|
||||||
{
|
{
|
||||||
PyTypeObject *newbase, *oldbase;
|
PyTypeObject *newbase, *oldbase;
|
||||||
|
|
||||||
if (new->tp_dealloc != old->tp_dealloc ||
|
if (newto->tp_dealloc != oldto->tp_dealloc ||
|
||||||
new->tp_free != old->tp_free)
|
newto->tp_free != oldto->tp_free)
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"%s assignment: "
|
"%s assignment: "
|
||||||
"'%s' deallocator differs from '%s'",
|
"'%s' deallocator differs from '%s'",
|
||||||
attr,
|
attr,
|
||||||
new->tp_name,
|
newto->tp_name,
|
||||||
old->tp_name);
|
oldto->tp_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
newbase = new;
|
newbase = newto;
|
||||||
oldbase = old;
|
oldbase = oldto;
|
||||||
while (equiv_structs(newbase, newbase->tp_base))
|
while (equiv_structs(newbase, newbase->tp_base))
|
||||||
newbase = newbase->tp_base;
|
newbase = newbase->tp_base;
|
||||||
while (equiv_structs(oldbase, oldbase->tp_base))
|
while (equiv_structs(oldbase, oldbase->tp_base))
|
||||||
|
|
@ -2474,8 +2474,8 @@ compatible_for_assignment(PyTypeObject* old, PyTypeObject* new, char* attr)
|
||||||
"%s assignment: "
|
"%s assignment: "
|
||||||
"'%s' object layout differs from '%s'",
|
"'%s' object layout differs from '%s'",
|
||||||
attr,
|
attr,
|
||||||
new->tp_name,
|
newto->tp_name,
|
||||||
old->tp_name);
|
oldto->tp_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2485,8 +2485,8 @@ compatible_for_assignment(PyTypeObject* old, PyTypeObject* new, char* attr)
|
||||||
static int
|
static int
|
||||||
object_set_class(PyObject *self, PyObject *value, void *closure)
|
object_set_class(PyObject *self, PyObject *value, void *closure)
|
||||||
{
|
{
|
||||||
PyTypeObject *old = self->ob_type;
|
PyTypeObject *oldto = self->ob_type;
|
||||||
PyTypeObject *new;
|
PyTypeObject *newto;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
|
@ -2499,18 +2499,18 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
|
||||||
value->ob_type->tp_name);
|
value->ob_type->tp_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
new = (PyTypeObject *)value;
|
newto = (PyTypeObject *)value;
|
||||||
if (!(new->tp_flags & Py_TPFLAGS_HEAPTYPE) ||
|
if (!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) ||
|
||||||
!(old->tp_flags & Py_TPFLAGS_HEAPTYPE))
|
!(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE))
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"__class__ assignment: only for heap types");
|
"__class__ assignment: only for heap types");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (compatible_for_assignment(new, old, "__class__")) {
|
if (compatible_for_assignment(newto, oldto, "__class__")) {
|
||||||
Py_INCREF(new);
|
Py_INCREF(newto);
|
||||||
self->ob_type = new;
|
self->ob_type = newto;
|
||||||
Py_DECREF(old);
|
Py_DECREF(oldto);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -3332,7 +3332,7 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
int result;
|
int result;
|
||||||
PyObject *list, *ref, *new;
|
PyObject *list, *ref, *newobj;
|
||||||
|
|
||||||
list = base->tp_subclasses;
|
list = base->tp_subclasses;
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
|
|
@ -3341,16 +3341,16 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
assert(PyList_Check(list));
|
assert(PyList_Check(list));
|
||||||
new = PyWeakref_NewRef((PyObject *)type, NULL);
|
newobj = PyWeakref_NewRef((PyObject *)type, NULL);
|
||||||
i = PyList_GET_SIZE(list);
|
i = PyList_GET_SIZE(list);
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
ref = PyList_GET_ITEM(list, i);
|
ref = PyList_GET_ITEM(list, i);
|
||||||
assert(PyWeakref_CheckRef(ref));
|
assert(PyWeakref_CheckRef(ref));
|
||||||
if (PyWeakref_GET_OBJECT(ref) == Py_None)
|
if (PyWeakref_GET_OBJECT(ref) == Py_None)
|
||||||
return PyList_SetItem(list, i, new);
|
return PyList_SetItem(list, i, newobj);
|
||||||
}
|
}
|
||||||
result = PyList_Append(list, new);
|
result = PyList_Append(list, newobj);
|
||||||
Py_DECREF(new);
|
Py_DECREF(newobj);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5746,7 +5746,7 @@ static PyObject *
|
||||||
super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
{
|
{
|
||||||
superobject *su = (superobject *)self;
|
superobject *su = (superobject *)self;
|
||||||
superobject *new;
|
superobject *newobj;
|
||||||
|
|
||||||
if (obj == NULL || obj == Py_None || su->obj != NULL) {
|
if (obj == NULL || obj == Py_None || su->obj != NULL) {
|
||||||
/* Not binding to an object, or already bound */
|
/* Not binding to an object, or already bound */
|
||||||
|
|
@ -5763,16 +5763,16 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
PyTypeObject *obj_type = supercheck(su->type, obj);
|
PyTypeObject *obj_type = supercheck(su->type, obj);
|
||||||
if (obj_type == NULL)
|
if (obj_type == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
new = (superobject *)PySuper_Type.tp_new(&PySuper_Type,
|
newobj = (superobject *)PySuper_Type.tp_new(&PySuper_Type,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (new == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_INCREF(su->type);
|
Py_INCREF(su->type);
|
||||||
Py_INCREF(obj);
|
Py_INCREF(obj);
|
||||||
new->type = su->type;
|
newobj->type = su->type;
|
||||||
new->obj = obj;
|
newobj->obj = obj;
|
||||||
new->obj_type = obj_type;
|
newobj->obj_type = obj_type;
|
||||||
return (PyObject *)new;
|
return (PyObject *)newobj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ int unicode_resize(register PyUnicodeObject *unicode,
|
||||||
oldstr = unicode->str;
|
oldstr = unicode->str;
|
||||||
PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1);
|
PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1);
|
||||||
if (!unicode->str) {
|
if (!unicode->str) {
|
||||||
unicode->str = oldstr;
|
unicode->str = (Py_UNICODE *)oldstr;
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1884,7 +1884,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
|
||||||
Py_DECREF(m);
|
Py_DECREF(m);
|
||||||
if (api == NULL)
|
if (api == NULL)
|
||||||
goto ucnhashError;
|
goto ucnhashError;
|
||||||
ucnhash_CAPI = PyCObject_AsVoidPtr(api);
|
ucnhash_CAPI = (_PyUnicode_Name_CAPI *)PyCObject_AsVoidPtr(api);
|
||||||
Py_DECREF(api);
|
Py_DECREF(api);
|
||||||
if (ucnhash_CAPI == NULL)
|
if (ucnhash_CAPI == NULL)
|
||||||
goto ucnhashError;
|
goto ucnhashError;
|
||||||
|
|
@ -2499,8 +2499,8 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
|
||||||
/* current output position */
|
/* current output position */
|
||||||
Py_ssize_t respos = 0;
|
Py_ssize_t respos = 0;
|
||||||
Py_ssize_t ressize;
|
Py_ssize_t ressize;
|
||||||
char *encoding = (limit == 256) ? "latin-1" : "ascii";
|
const char *encoding = (limit == 256) ? "latin-1" : "ascii";
|
||||||
char *reason = (limit == 256) ? "ordinal not in range(256)" : "ordinal not in range(128)";
|
const char *reason = (limit == 256) ? "ordinal not in range(256)" : "ordinal not in range(128)";
|
||||||
PyObject *errorHandler = NULL;
|
PyObject *errorHandler = NULL;
|
||||||
PyObject *exc = NULL;
|
PyObject *exc = NULL;
|
||||||
/* the following variable is used for caching string comparisons
|
/* the following variable is used for caching string comparisons
|
||||||
|
|
@ -6488,7 +6488,8 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
|
||||||
return PyUnicode_FromUnicode(NULL, 0);
|
return PyUnicode_FromUnicode(NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
source_buf = PyUnicode_AS_UNICODE((PyObject*)self);
|
source_buf = PyUnicode_AS_UNICODE((PyObject*)self);
|
||||||
result_buf = PyMem_MALLOC(slicelength*sizeof(Py_UNICODE));
|
result_buf = (Py_UNICODE *)PyMem_MALLOC(slicelength*
|
||||||
|
sizeof(Py_UNICODE));
|
||||||
|
|
||||||
if (result_buf == NULL)
|
if (result_buf == NULL)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue