Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03657cf

Browse files
committed
replace PyXXX_Length calls with PyXXX_Size calls
1 parent 6253f83 commit 03657cf

14 files changed

Lines changed: 30 additions & 29 deletions

Modules/_sre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ _compile(PyObject* self_, PyObject* args)
11271127
if (!code)
11281128
return NULL;
11291129

1130-
n = PySequence_Length(code);
1130+
n = PySequence_Size(code);
11311131

11321132
self = PyObject_NEW_VAR(PatternObject, &Pattern_Type, 100*n);
11331133
if (!self) {

Modules/_tkinter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ Tkinter_Flatten(PyObject* self, PyObject* args)
19341934
if (!PyArg_ParseTuple(args, "O:_flatten", &item))
19351935
return NULL;
19361936

1937-
context.maxsize = PySequence_Length(item);
1937+
context.maxsize = PySequence_Size(item);
19381938
if (context.maxsize <= 0)
19391939
return PyTuple_New(0);
19401940

Modules/almodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo)
176176
case AL_INT32_ELEM:
177177
case AL_RESOURCE_ELEM:
178178
case AL_ENUM_ELEM:
179-
param->sizeIn = PySequence_Length(value);
179+
param->sizeIn = PySequence_Size(value);
180180
param->value.ptr = PyMem_NEW(int, param->sizeIn);
181181
stepsize = sizeof(int);
182182
break;
183183
case AL_INT64_ELEM:
184184
case AL_FIXED_ELEM:
185-
param->sizeIn = PySequence_Length(value);
185+
param->sizeIn = PySequence_Size(value);
186186
param->value.ptr = PyMem_NEW(long long, param->sizeIn);
187187
stepsize = sizeof(long long);
188188
break;

Modules/cPickle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ save_inst(Picklerobject *self, PyObject *args) {
14661466
PyObject_CallObject(getinitargs_func, empty_tuple))
14671467
goto finally;
14681468

1469-
if ((len = PyObject_Length(class_args)) < 0)
1469+
if ((len = PyObject_Size(class_args)) < 0)
14701470
goto finally;
14711471

14721472
for (i = 0; i < len; i++) {
@@ -2874,7 +2874,7 @@ Instance_New(PyObject *cls, PyObject *args) {
28742874
if (PyClass_Check(cls)) {
28752875
int l;
28762876

2877-
if ((l=PyObject_Length(args)) < 0) goto err;
2877+
if ((l=PyObject_Size(args)) < 0) goto err;
28782878
UNLESS (l) {
28792879
PyObject *__getinitargs__;
28802880

Modules/cStringIO.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ O_writelines(Oobject *self, PyObject *args) {
367367
Py_DECREF(string_module);
368368
}
369369

370-
if (PyObject_Length(args) == -1) {
370+
if (PyObject_Size(args) == -1) {
371371
return NULL;
372372
}
373373

Modules/parsermodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ parser_tuple2ast(PyAST_Object *self, PyObject *args, PyObject *kw)
610610
* so we can DECREF it after the check. But we really should accept
611611
* lists as well as tuples at the very least.
612612
*/
613-
ok = PyObject_Length(tuple) >= 2;
613+
ok = PyObject_Size(tuple) >= 2;
614614
if (ok) {
615615
temp = PySequence_GetItem(tuple, 0);
616616
ok = (temp != NULL) && PyInt_Check(temp);
@@ -626,7 +626,7 @@ parser_tuple2ast(PyAST_Object *self, PyObject *args, PyObject *kw)
626626
}
627627
if (ok) {
628628
temp = PySequence_GetItem(tuple, 1);
629-
ok = (temp != NULL) && PyObject_Length(temp) >= 2;
629+
ok = (temp != NULL) && PyObject_Size(temp) >= 2;
630630
if (ok) {
631631
PyObject *temp2 = PySequence_GetItem(temp, 0);
632632
if (temp2 != NULL) {
@@ -693,7 +693,7 @@ parser_tuple2ast(PyAST_Object *self, PyObject *args, PyObject *kw)
693693
static int
694694
check_terminal_tuple(PyObject *elem)
695695
{
696-
int len = PyObject_Length(elem);
696+
int len = PyObject_Size(elem);
697697
int res = 1;
698698
char* str = "Illegal terminal symbol; bad node length.";
699699

@@ -731,7 +731,7 @@ check_terminal_tuple(PyObject *elem)
731731
static node*
732732
build_node_children(PyObject *tuple, node *root, int *line_num)
733733
{
734-
int len = PyObject_Length(tuple);
734+
int len = PyObject_Size(tuple);
735735
int i;
736736

737737
for (i = 1; i < len; ++i) {
@@ -771,7 +771,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
771771
(void) strcpy(strn, PyString_AS_STRING(temp));
772772
Py_DECREF(temp);
773773

774-
if (PyObject_Length(elem) == 3) {
774+
if (PyObject_Size(elem) == 3) {
775775
PyObject* temp = PySequence_GetItem(elem, 2);
776776
*line_num = PyInt_AsLong(temp);
777777
Py_DECREF(temp);

Modules/posixmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ posix_execve(PyObject *self, PyObject *args)
14171417
}
14181418
argvlist[argc] = NULL;
14191419

1420-
i = PyMapping_Length(env);
1420+
i = PyMapping_Size(env);
14211421
envlist = PyMem_NEW(char *, i + 1);
14221422
if (envlist == NULL) {
14231423
PyErr_NoMemory();
@@ -1610,7 +1610,7 @@ posix_spawnve(PyObject *self, PyObject *args)
16101610
}
16111611
argvlist[argc] = NULL;
16121612

1613-
i = PyMapping_Length(env);
1613+
i = PyMapping_Size(env);
16141614
envlist = PyMem_NEW(char *, i + 1);
16151615
if (envlist == NULL) {
16161616
PyErr_NoMemory();

Modules/stropmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ strop_joinfields(PyObject *self, PyObject *args)
190190
seplen = 1;
191191
}
192192

193-
seqlen = PySequence_Length(seq);
193+
seqlen = PySequence_Size(seq);
194194
if (seqlen < 0 && PyErr_Occurred())
195195
return NULL;
196196

Objects/listobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ listextend(PyListObject *self, PyObject *args)
563563
if (!b)
564564
return NULL;
565565

566-
if (PyObject_Length(b) == 0)
566+
if (PyObject_Size(b) == 0)
567567
/* short circuit when b is empty */
568568
goto ok;
569569

@@ -585,7 +585,7 @@ listextend(PyListObject *self, PyObject *args)
585585
}
586586
}
587587

588-
blen = PyObject_Length(b);
588+
blen = PyObject_Size(b);
589589

590590
/* resize a using idiom */
591591
items = self->ob_item;

Objects/stringobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ string_join(PyStringObject *self, PyObject *args)
759759
/* From here on out, errors go through finally: for proper
760760
* reference count manipulations.
761761
*/
762-
seqlen = PySequence_Length(seq);
762+
seqlen = PySequence_Size(seq);
763763
if (seqlen == 1) {
764764
item = PySequence_Fast_GET_ITEM(seq, 0);
765765
Py_INCREF(item);

0 commit comments

Comments
 (0)