Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a701388d
Commit
a701388d
authored
Apr 05, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in the stable ABI.
parent
d4dc6dc9
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
38 additions
and
35 deletions
+38
-35
Include/iterobject.h
Include/iterobject.h
+0
-2
Include/object.h
Include/object.h
+5
-0
Modules/arraymodule.c
Modules/arraymodule.c
+1
-1
Objects/bytearrayobject.c
Objects/bytearrayobject.c
+2
-2
Objects/bytesobject.c
Objects/bytesobject.c
+2
-2
Objects/dictobject.c
Objects/dictobject.c
+1
-1
Objects/iterobject.c
Objects/iterobject.c
+4
-17
Objects/listobject.c
Objects/listobject.c
+3
-3
Objects/object.c
Objects/object.c
+13
-0
Objects/rangeobject.c
Objects/rangeobject.c
+2
-2
Objects/setobject.c
Objects/setobject.c
+1
-1
Objects/tupleobject.c
Objects/tupleobject.c
+2
-2
Objects/unicodeobject.c
Objects/unicodeobject.c
+2
-2
No files found.
Include/iterobject.h
View file @
a701388d
...
@@ -18,8 +18,6 @@ PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
...
@@ -18,8 +18,6 @@ PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
PyAPI_FUNC
(
PyObject
*
)
PyCallIter_New
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyCallIter_New
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
_PyIter_GetBuiltin
(
const
char
*
iter
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
Include/object.h
View file @
a701388d
...
@@ -535,6 +535,11 @@ PyAPI_FUNC(int)
...
@@ -535,6 +535,11 @@ PyAPI_FUNC(int)
_PyObject_GenericSetAttrWithDict
(
PyObject
*
,
PyObject
*
,
_PyObject_GenericSetAttrWithDict
(
PyObject
*
,
PyObject
*
,
PyObject
*
,
PyObject
*
);
PyObject
*
,
PyObject
*
);
/* Helper to look up a builtin object */
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
_PyObject_GetBuiltin
(
const
char
*
name
);
#endif
/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a
/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a
list of strings. PyObject_Dir(NULL) is like builtins.dir(),
list of strings. PyObject_Dir(NULL) is like builtins.dir(),
...
...
Modules/arraymodule.c
View file @
a701388d
...
@@ -2756,7 +2756,7 @@ arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg)
...
@@ -2756,7 +2756,7 @@ arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg)
static
PyObject
*
static
PyObject
*
arrayiter_reduce
(
arrayiterobject
*
it
)
arrayiter_reduce
(
arrayiterobject
*
it
)
{
{
return
Py_BuildValue
(
"N(O)n"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)n"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
ao
,
it
->
index
);
it
->
ao
,
it
->
index
);
}
}
...
...
Objects/bytearrayobject.c
View file @
a701388d
...
@@ -3018,13 +3018,13 @@ static PyObject *
...
@@ -3018,13 +3018,13 @@ static PyObject *
bytearrayiter_reduce
(
bytesiterobject
*
it
)
bytearrayiter_reduce
(
bytesiterobject
*
it
)
{
{
if
(
it
->
it_seq
!=
NULL
)
{
if
(
it
->
it_seq
!=
NULL
)
{
return
Py_BuildValue
(
"N(O)n"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)n"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
}
else
{
}
else
{
PyObject
*
u
=
PyUnicode_FromUnicode
(
NULL
,
0
);
PyObject
*
u
=
PyUnicode_FromUnicode
(
NULL
,
0
);
if
(
u
==
NULL
)
if
(
u
==
NULL
)
return
NULL
;
return
NULL
;
return
Py_BuildValue
(
"N(N)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
u
);
return
Py_BuildValue
(
"N(N)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
u
);
}
}
}
}
...
...
Objects/bytesobject.c
View file @
a701388d
...
@@ -3078,13 +3078,13 @@ static PyObject *
...
@@ -3078,13 +3078,13 @@ static PyObject *
striter_reduce
(
striterobject
*
it
)
striter_reduce
(
striterobject
*
it
)
{
{
if
(
it
->
it_seq
!=
NULL
)
{
if
(
it
->
it_seq
!=
NULL
)
{
return
Py_BuildValue
(
"N(O)n"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)n"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
}
else
{
}
else
{
PyObject
*
u
=
PyUnicode_FromUnicode
(
NULL
,
0
);
PyObject
*
u
=
PyUnicode_FromUnicode
(
NULL
,
0
);
if
(
u
==
NULL
)
if
(
u
==
NULL
)
return
NULL
;
return
NULL
;
return
Py_BuildValue
(
"N(N)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
u
);
return
Py_BuildValue
(
"N(N)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
u
);
}
}
}
}
...
...
Objects/dictobject.c
View file @
a701388d
...
@@ -2610,7 +2610,7 @@ dictiter_reduce(dictiterobject *di)
...
@@ -2610,7 +2610,7 @@ dictiter_reduce(dictiterobject *di)
Py_DECREF
(
list
);
Py_DECREF
(
list
);
return
NULL
;
return
NULL
;
}
}
return
Py_BuildValue
(
"N(N)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
list
);
return
Py_BuildValue
(
"N(N)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
list
);
}
}
/***********************************************/
/***********************************************/
...
...
Objects/iterobject.c
View file @
a701388d
...
@@ -2,19 +2,6 @@
...
@@ -2,19 +2,6 @@
#include "Python.h"
#include "Python.h"
/* Convenience function to get builtins.iter or builtins.reversed */
PyObject
*
_PyIter_GetBuiltin
(
const
char
*
iter
)
{
PyObject
*
mod
,
*
attr
;
mod
=
PyImport_ImportModule
(
"builtins"
);
if
(
mod
==
NULL
)
return
NULL
;
attr
=
PyObject_GetAttrString
(
mod
,
iter
);
Py_DECREF
(
mod
);
return
attr
;
}
typedef
struct
{
typedef
struct
{
PyObject_HEAD
PyObject_HEAD
long
it_index
;
long
it_index
;
...
@@ -105,10 +92,10 @@ static PyObject *
...
@@ -105,10 +92,10 @@ static PyObject *
iter_reduce
(
seqiterobject
*
it
)
iter_reduce
(
seqiterobject
*
it
)
{
{
if
(
it
->
it_seq
!=
NULL
)
if
(
it
->
it_seq
!=
NULL
)
return
Py_BuildValue
(
"N(O)n"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)n"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
else
else
return
Py_BuildValue
(
"N(())"
,
_Py
Iter
_GetBuiltin
(
"iter"
));
return
Py_BuildValue
(
"N(())"
,
_Py
Object
_GetBuiltin
(
"iter"
));
}
}
PyDoc_STRVAR
(
reduce_doc
,
"Return state information for pickling."
);
PyDoc_STRVAR
(
reduce_doc
,
"Return state information for pickling."
);
...
@@ -242,10 +229,10 @@ static PyObject *
...
@@ -242,10 +229,10 @@ static PyObject *
calliter_reduce
(
calliterobject
*
it
)
calliter_reduce
(
calliterobject
*
it
)
{
{
if
(
it
->
it_callable
!=
NULL
&&
it
->
it_sentinel
!=
NULL
)
if
(
it
->
it_callable
!=
NULL
&&
it
->
it_sentinel
!=
NULL
)
return
Py_BuildValue
(
"N(OO)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(OO)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_callable
,
it
->
it_sentinel
);
it
->
it_callable
,
it
->
it_sentinel
);
else
else
return
Py_BuildValue
(
"N(())"
,
_Py
Iter
_GetBuiltin
(
"iter"
));
return
Py_BuildValue
(
"N(())"
,
_Py
Object
_GetBuiltin
(
"iter"
));
}
}
static
PyMethodDef
calliter_methods
[]
=
{
static
PyMethodDef
calliter_methods
[]
=
{
...
...
Objects/listobject.c
View file @
a701388d
...
@@ -2949,17 +2949,17 @@ listiter_reduce_general(void *_it, int forward)
...
@@ -2949,17 +2949,17 @@ listiter_reduce_general(void *_it, int forward)
if
(
forward
)
{
if
(
forward
)
{
listiterobject
*
it
=
(
listiterobject
*
)
_it
;
listiterobject
*
it
=
(
listiterobject
*
)
_it
;
if
(
it
->
it_seq
)
if
(
it
->
it_seq
)
return
Py_BuildValue
(
"N(O)l"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)l"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
}
else
{
}
else
{
listreviterobject
*
it
=
(
listreviterobject
*
)
_it
;
listreviterobject
*
it
=
(
listreviterobject
*
)
_it
;
if
(
it
->
it_seq
)
if
(
it
->
it_seq
)
return
Py_BuildValue
(
"N(O)n"
,
_Py
Iter
_GetBuiltin
(
"reversed"
),
return
Py_BuildValue
(
"N(O)n"
,
_Py
Object
_GetBuiltin
(
"reversed"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
}
}
/* empty iterator, create an empty list */
/* empty iterator, create an empty list */
list
=
PyList_New
(
0
);
list
=
PyList_New
(
0
);
if
(
list
==
NULL
)
if
(
list
==
NULL
)
return
NULL
;
return
NULL
;
return
Py_BuildValue
(
"N(N)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
list
);
return
Py_BuildValue
(
"N(N)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
list
);
}
}
Objects/object.c
View file @
a701388d
...
@@ -1026,6 +1026,19 @@ PyObject_SelfIter(PyObject *obj)
...
@@ -1026,6 +1026,19 @@ PyObject_SelfIter(PyObject *obj)
return
obj
;
return
obj
;
}
}
/* Convenience function to get a builtin from its name */
PyObject
*
_PyObject_GetBuiltin
(
const
char
*
name
)
{
PyObject
*
mod
,
*
attr
;
mod
=
PyImport_ImportModule
(
"builtins"
);
if
(
mod
==
NULL
)
return
NULL
;
attr
=
PyObject_GetAttrString
(
mod
,
name
);
Py_DECREF
(
mod
);
return
attr
;
}
/* Helper used when the __next__ method is removed from a type:
/* Helper used when the __next__ method is removed from a type:
tp_iternext is never NULL and can be safely called without checking
tp_iternext is never NULL and can be safely called without checking
on every iteration.
on every iteration.
...
...
Objects/rangeobject.c
View file @
a701388d
...
@@ -985,7 +985,7 @@ rangeiter_reduce(rangeiterobject *r)
...
@@ -985,7 +985,7 @@ rangeiter_reduce(rangeiterobject *r)
if
(
range
==
NULL
)
if
(
range
==
NULL
)
goto
err
;
goto
err
;
/* return the result */
/* return the result */
return
Py_BuildValue
(
"N(N)i"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
range
,
r
->
index
);
return
Py_BuildValue
(
"N(N)i"
,
_Py
Object
_GetBuiltin
(
"iter"
),
range
,
r
->
index
);
err:
err:
Py_XDECREF
(
start
);
Py_XDECREF
(
start
);
Py_XDECREF
(
stop
);
Py_XDECREF
(
stop
);
...
@@ -1171,7 +1171,7 @@ longrangeiter_reduce(longrangeiterobject *r)
...
@@ -1171,7 +1171,7 @@ longrangeiter_reduce(longrangeiterobject *r)
}
}
/* return the result */
/* return the result */
return
Py_BuildValue
(
"N(N)O"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
range
,
r
->
index
);
return
Py_BuildValue
(
"N(N)O"
,
_Py
Object
_GetBuiltin
(
"iter"
),
range
,
r
->
index
);
}
}
static
PyObject
*
static
PyObject
*
...
...
Objects/setobject.c
View file @
a701388d
...
@@ -856,7 +856,7 @@ setiter_reduce(setiterobject *si)
...
@@ -856,7 +856,7 @@ setiter_reduce(setiterobject *si)
Py_DECREF
(
list
);
Py_DECREF
(
list
);
return
NULL
;
return
NULL
;
}
}
return
Py_BuildValue
(
"N(N)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
list
);
return
Py_BuildValue
(
"N(N)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
list
);
}
}
PyDoc_STRVAR
(
reduce_doc
,
"Return state information for pickling."
);
PyDoc_STRVAR
(
reduce_doc
,
"Return state information for pickling."
);
...
...
Objects/tupleobject.c
View file @
a701388d
...
@@ -971,10 +971,10 @@ static PyObject *
...
@@ -971,10 +971,10 @@ static PyObject *
tupleiter_reduce
(
tupleiterobject
*
it
)
tupleiter_reduce
(
tupleiterobject
*
it
)
{
{
if
(
it
->
it_seq
)
if
(
it
->
it_seq
)
return
Py_BuildValue
(
"N(O)l"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)l"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
else
else
return
Py_BuildValue
(
"N(())"
,
_Py
Iter
_GetBuiltin
(
"iter"
));
return
Py_BuildValue
(
"N(())"
,
_Py
Object
_GetBuiltin
(
"iter"
));
}
}
static
PyObject
*
static
PyObject
*
...
...
Objects/unicodeobject.c
View file @
a701388d
...
@@ -14386,13 +14386,13 @@ static PyObject *
...
@@ -14386,13 +14386,13 @@ static PyObject *
unicodeiter_reduce
(
unicodeiterobject
*
it
)
unicodeiter_reduce
(
unicodeiterobject
*
it
)
{
{
if
(
it
->
it_seq
!=
NULL
)
{
if
(
it
->
it_seq
!=
NULL
)
{
return
Py_BuildValue
(
"N(O)n"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
return
Py_BuildValue
(
"N(O)n"
,
_Py
Object
_GetBuiltin
(
"iter"
),
it
->
it_seq
,
it
->
it_index
);
it
->
it_seq
,
it
->
it_index
);
}
else
{
}
else
{
PyObject
*
u
=
PyUnicode_FromUnicode
(
NULL
,
0
);
PyObject
*
u
=
PyUnicode_FromUnicode
(
NULL
,
0
);
if
(
u
==
NULL
)
if
(
u
==
NULL
)
return
NULL
;
return
NULL
;
return
Py_BuildValue
(
"N(N)"
,
_Py
Iter
_GetBuiltin
(
"iter"
),
u
);
return
Py_BuildValue
(
"N(N)"
,
_Py
Object
_GetBuiltin
(
"iter"
),
u
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment