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

Skip to content

Commit 6253f83

Browse files
committed
change abstract size functions PySequence_Size &c.
add macros for backwards compatibility with C source
1 parent f981c8f commit 6253f83

3 files changed

Lines changed: 21 additions & 15 deletions

File tree

Include/abstract.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
381381
equivalent to the Python expression: type(o).
382382
*/
383383

384-
DL_IMPORT(int) PyObject_Length(PyObject *o);
384+
DL_IMPORT(int) PyObject_Size(PyObject *o);
385+
386+
#define PyObject_Length(O) PyObject_Size((O))
385387

386388
/*
387-
Return the length of object o. If the object, o, provides
388-
both sequence and mapping protocols, the sequence length is
389+
Return the size of object o. If the object, o, provides
390+
both sequence and mapping protocols, the sequence size is
389391
returned. On error, -1 is returned. This is the equivalent
390392
to the Python expression: len(o).
391393
@@ -681,10 +683,12 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
681683
682684
*/
683685

684-
DL_IMPORT(int) PySequence_Length(PyObject *o);
686+
DL_IMPORT(int) PySequence_Size(PyObject *o);
687+
688+
#define PySequence_Length(O) PySequence_Size((O))
685689

686690
/*
687-
Return the length of sequence object o, or -1 on failure.
691+
Return the size of sequence object o, or -1 on failure.
688692
689693
*/
690694

@@ -833,7 +837,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
833837
This function always succeeds.
834838
*/
835839

836-
DL_IMPORT(int) PyMapping_Length(PyObject *o);
840+
DL_IMPORT(int) PyMapping_Size(PyObject *o);
841+
842+
#define PyMapping_Length(O) PyMapping_Size((O))
837843

838844
/*
839845
Returns the number of keys in object o on success, and -1 on

Objects/abstract.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PyObject_Type(PyObject *o)
6262
}
6363

6464
int
65-
PyObject_Length(PyObject *o)
65+
PyObject_Size(PyObject *o)
6666
{
6767
PySequenceMethods *m;
6868

@@ -75,7 +75,7 @@ PyObject_Length(PyObject *o)
7575
if (m && m->sq_length)
7676
return m->sq_length(o);
7777

78-
return PyMapping_Length(o);
78+
return PyMapping_Size(o);
7979
}
8080

8181
PyObject *
@@ -803,7 +803,7 @@ PySequence_Check(PyObject *s)
803803
}
804804

805805
int
806-
PySequence_Length(PyObject *s)
806+
PySequence_Size(PyObject *s)
807807
{
808808
PySequenceMethods *m;
809809

@@ -1036,7 +1036,7 @@ PySequence_Tuple(PyObject *v)
10361036
if (m && m->sq_item) {
10371037
int i;
10381038
PyObject *t;
1039-
int n = PySequence_Length(v);
1039+
int n = PySequence_Size(v);
10401040
if (n < 0)
10411041
return NULL;
10421042
t = PyTuple_New(n);
@@ -1087,7 +1087,7 @@ PySequence_List(PyObject *v)
10871087
if (m && m->sq_item) {
10881088
int i;
10891089
PyObject *l;
1090-
int n = PySequence_Length(v);
1090+
int n = PySequence_Size(v);
10911091
if (n < 0)
10921092
return NULL;
10931093
l = PyList_New(n);
@@ -1152,7 +1152,7 @@ PySequence_Count(PyObject *s, PyObject *o)
11521152
return -1;
11531153
}
11541154

1155-
l = PySequence_Length(s);
1155+
l = PySequence_Size(s);
11561156
if (l < 0)
11571157
return -1;
11581158

@@ -1232,7 +1232,7 @@ PySequence_Index(PyObject *s, PyObject *o)
12321232
return -1;
12331233
}
12341234

1235-
l = PySequence_Length(s);
1235+
l = PySequence_Size(s);
12361236
if (l < 0)
12371237
return -1;
12381238

@@ -1261,7 +1261,7 @@ PyMapping_Check(PyObject *o)
12611261
}
12621262

12631263
int
1264-
PyMapping_Length(PyObject *o)
1264+
PyMapping_Size(PyObject *o)
12651265
{
12661266
PyMappingMethods *m;
12671267

Objects/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ PyTypeObject *_Py_cobject_hack = &PyCObject_Type;
958958

959959

960960
/* Hack to force loading of abstract.o */
961-
int (*_Py_abstract_hack)(PyObject *) = &PyObject_Length;
961+
int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size;
962962

963963

964964
/* Python's malloc wrappers (see mymalloc.h) */

0 commit comments

Comments
 (0)