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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
5e7c718a
Commit
5e7c718a
authored
Jul 31, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guard the usage of the new PEP 492 async type slots by an explicit feature macro
parent
6931f234
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
18 deletions
+28
-18
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+7
-7
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+21
-11
No files found.
Cython/Utility/Coroutine.c
View file @
5e7c718a
...
...
@@ -118,7 +118,7 @@ static CYTHON_INLINE PyObject* __Pyx_Coroutine_AIter_Yield_From(__pyx_CoroutineO
//@requires: CoroutineYieldFrom
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_AIter_Yield_From
(
__pyx_CoroutineObject
*
gen
,
PyObject
*
source
)
{
#if
PY_MAJOR_VERSION >= 3
#if
CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
source
);
if
(
likely
(
am
&&
am
->
am_anext
))
{
// Starting with CPython 3.5.2, __aiter__ should return
...
...
@@ -180,7 +180,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
// adapted from genobject.c in Py3.5
static
PyObject
*
__Pyx__Coroutine_GetAwaitableIter
(
PyObject
*
obj
)
{
PyObject
*
res
;
#if CYTHON_USE_
TYPE_SLOTS && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_
ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_await
))
{
res
=
(
*
am
->
am_await
)(
obj
);
...
...
@@ -257,7 +257,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro
//@requires: ObjectHandling.c::PyObjectCallMethod0
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_GetAsyncIter
(
PyObject
*
obj
)
{
#if
PY_MAJOR_VERSION >= 3
#if
CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_aiter
))
{
return
(
*
am
->
am_aiter
)(
obj
);
...
...
@@ -283,7 +283,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
}
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_AsyncIterNext
(
PyObject
*
obj
)
{
#if
PY_MAJOR_VERSION >= 3
#if
CYTHON_USE_ASYNC_SLOTS
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_anext
))
{
return
(
*
am
->
am_anext
)(
obj
);
...
...
@@ -1280,7 +1280,7 @@ static PyGetSetDef __pyx_Coroutine_getsets[] = {
{
0
,
0
,
0
,
0
,
0
}
};
#if
PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
#if
CYTHON_USE_ASYNC_SLOTS
static
__Pyx_PyAsyncMethodsStruct
__pyx_Coroutine_as_async
=
{
__Pyx_Coroutine_await
,
/*am_await*/
0
,
/*am_aiter*/
...
...
@@ -1297,8 +1297,8 @@ static PyTypeObject __pyx_CoroutineType_type = {
0
,
/*tp_print*/
0
,
/*tp_getattr*/
0
,
/*tp_setattr*/
#if
PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
&
__pyx_Coroutine_as_async
,
/*tp_as_async (tp_reserved)*/
#if
CYTHON_USE_ASYNC_SLOTS
&
__pyx_Coroutine_as_async
,
/*tp_as_async (tp_reserved)
- Py3 only!
*/
#else
0
,
/*tp_reserved*/
#endif
...
...
Cython/Utility/ModuleSetupCode.c
View file @
5e7c718a
...
...
@@ -37,6 +37,8 @@
#define CYTHON_COMPILING_IN_CPYTHON 0
#undef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS
...
...
@@ -55,6 +57,12 @@
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#if PY_MAJOR_VERSION < 3
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#ifndef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 1
#endif
...
...
@@ -253,18 +261,20 @@
// backport of PyAsyncMethods from Py3.5 to older Py3.x versions
// (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
typedef
struct
{
unaryfunc
am_await
;
unaryfunc
am_aiter
;
unaryfunc
am_anext
;
}
__Pyx_PyAsyncMethodsStruct
;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#if CYTHON_USE_ASYNC_SLOTS
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#else
typedef
struct
{
unaryfunc
am_await
;
unaryfunc
am_aiter
;
unaryfunc
am_anext
;
}
__Pyx_PyAsyncMethodsStruct
;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#endif
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
// restrict
...
...
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