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
d6109ba4
Commit
d6109ba4
authored
May 29, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use original "types.coroutine" in PEP 492 test if available
parent
c9245a28
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
19 deletions
+32
-19
tests/run/test_coroutines_pep492.pyx
tests/run/test_coroutines_pep492.pyx
+32
-19
No files found.
tests/run/test_coroutines_pep492.pyx
View file @
d6109ba4
...
@@ -7,32 +7,45 @@ import gc
...
@@ -7,32 +7,45 @@ import gc
import
sys
import
sys
#import types
#import types
import
os.path
import
os.path
import
inspect
#
import inspect
import
unittest
import
unittest
import
warnings
import
warnings
import
contextlib
import
contextlib
# fake types.coroutine() decorator
try
:
class
types_coroutine
(
object
):
from
types
import
coroutine
as
types_coroutine
except
ImportError
:
# duck typed types.coroutine() decorator copied from types.py in Py3.5
class
types_coroutine
(
object
):
def
__init__
(
self
,
gen
):
def
__init__
(
self
,
gen
):
self
.
_gen
=
gen
self
.
_gen
=
gen
class
as_coroutine
(
object
)
:
class
GeneratorWrapper
:
def
__init__
(
self
,
gen
):
def
__init__
(
self
,
gen
):
self
.
_gen
=
gen
self
.
__wrapped__
=
gen
self
.
send
=
gen
.
send
self
.
send
=
gen
.
send
self
.
throw
=
gen
.
throw
self
.
throw
=
gen
.
throw
self
.
close
=
gen
.
close
self
.
close
=
gen
.
close
self
.
__name__
=
getattr
(
gen
,
'__name__'
,
None
)
def
__await__
(
self
):
self
.
__qualname__
=
getattr
(
gen
,
'__qualname__'
,
None
)
return
self
.
_gen
@
property
def
gi_code
(
self
):
return
self
.
__wrapped__
.
gi_code
@
property
def
gi_frame
(
self
):
return
self
.
__wrapped__
.
gi_frame
@
property
def
gi_running
(
self
):
return
self
.
__wrapped__
.
gi_running
def
__next__
(
self
):
return
next
(
self
.
__wrapped__
)
def
__iter__
(
self
):
def
__iter__
(
self
):
return
self
.
_gen
return
self
.
__wrapped__
__await__
=
__iter__
def
__call__
(
self
,
*
args
,
**
kwargs
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
self
.
as_coroutine
(
self
.
_gen
(
*
args
,
**
kwargs
))
return
self
.
GeneratorWrapper
(
self
.
_gen
(
*
args
,
**
kwargs
))
# compiled exec()
# compiled exec()
...
@@ -60,7 +73,7 @@ class AsyncYield:
...
@@ -60,7 +73,7 @@ class AsyncYield:
def
run_async
(
coro
):
def
run_async
(
coro
):
#assert coro.__class__ is types.GeneratorType
#assert coro.__class__ is types.GeneratorType
assert
coro
.
__class__
.
__name__
in
(
'coroutine'
,
'
as_coroutine
'
)
assert
coro
.
__class__
.
__name__
in
(
'coroutine'
,
'
GeneratorWrapper
'
)
buffer
=
[]
buffer
=
[]
result
=
None
result
=
None
...
...
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