Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
641cc04c
Commit
641cc04c
authored
Mar 25, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved next() utility code from Builtin.py to ObjectHandling.c
parent
4215bcb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
46 deletions
+48
-46
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+1
-46
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+47
-0
No files found.
Cython/Compiler/Builtin.py
View file @
641cc04c
...
...
@@ -31,52 +31,7 @@ proto = '''
#define __Pyx_abs_long(x) __Pyx_abs_int(x)
'''
)
iter_next_utility_code
=
UtilityCode
(
proto
=
"""
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL);
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*proto*/
"""
,
# copied from Py3's builtin_next()
impl
=
'''
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
PyObject* next;
iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(!iternext)) {
#else
if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
#endif
PyErr_Format(PyExc_TypeError,
"%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
return NULL;
}
next = iternext(iterator);
if (likely(next))
return next;
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_VERSION_HEX >= 0x03010000 || PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000
if (unlikely(iternext == &_PyObject_NextNotImplemented)) {
return NULL;
#endif
#endif
} else if (defval) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (unlikely(exc_type != PyExc_StopIteration) &&
!PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
return NULL;
PyErr_Clear();
}
Py_INCREF(defval);
return defval;
} else if (PyErr_Occurred()) {
return NULL;
} else {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
}
'''
)
iter_next_utility_code
=
UtilityCode
.
load_cached
(
"IterNext"
,
"ObjectHandling.c"
)
getattr3_utility_code
=
UtilityCode
(
proto
=
"""
...
...
Cython/Utility/ObjectHandling.c
View file @
641cc04c
...
...
@@ -152,6 +152,53 @@ bad:
return
-
1
;
}
/////////////// IterNext.proto ///////////////
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL);
static
CYTHON_INLINE
PyObject
*
__Pyx_PyIter_Next2
(
PyObject
*
,
PyObject
*
);
/*proto*/
/////////////// IterNext ///////////////
// originally copied from Py3's builtin_next()
static
CYTHON_INLINE
PyObject
*
__Pyx_PyIter_Next2
(
PyObject
*
iterator
,
PyObject
*
defval
)
{
PyObject
*
next
;
iternextfunc
iternext
=
Py_TYPE
(
iterator
)
->
tp_iternext
;
#if CYTHON_COMPILING_IN_CPYTHON
if
(
unlikely
(
!
iternext
))
{
#else
if
(
unlikely
(
!
iternext
)
||
unlikely
(
!
PyIter_Check
(
iterator
)))
{
#endif
PyErr_Format
(
PyExc_TypeError
,
"%.200s object is not an iterator"
,
Py_TYPE
(
iterator
)
->
tp_name
);
return
NULL
;
}
next
=
iternext
(
iterator
);
if
(
likely
(
next
))
return
next
;
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_VERSION_HEX >= 0x03010000 || PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000
if
(
unlikely
(
iternext
==
&
_PyObject_NextNotImplemented
))
{
return
NULL
;
#endif
#endif
}
else
if
(
defval
)
{
PyObject
*
exc_type
=
PyErr_Occurred
();
if
(
exc_type
)
{
if
(
unlikely
(
exc_type
!=
PyExc_StopIteration
)
&&
!
PyErr_GivenExceptionMatches
(
exc_type
,
PyExc_StopIteration
))
return
NULL
;
PyErr_Clear
();
}
Py_INCREF
(
defval
);
return
defval
;
}
else
if
(
PyErr_Occurred
())
{
return
NULL
;
}
else
{
PyErr_SetNone
(
PyExc_StopIteration
);
return
NULL
;
}
}
/////////////// IterFinish.proto ///////////////
static
CYTHON_INLINE
int
__Pyx_IterFinish
(
void
);
/*proto*/
...
...
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