File tree 4 files changed +29
-0
lines changed
4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 34
34
'pycodestyle~=2.7.0' ,
35
35
'pyOpenSSL~=19.0.0' ,
36
36
'mypy>=0.800' ,
37
+ CYTHON_DEPENDENCY ,
37
38
]
38
39
39
40
# Dependencies required to build documentation.
Original file line number Diff line number Diff line change
1
+ from cpython.pycapsule cimport PyCapsule_GetPointer
2
+
3
+
4
+ def capsule_equals (cap1 , cap2 ):
5
+ return PyCapsule_GetPointer(cap1, NULL ) == PyCapsule_GetPointer(cap2, NULL )
Original file line number Diff line number Diff line change
1
+ from uvloop import _testbase as tb
2
+
3
+
4
+ class Test_UV_Pointers (tb .UVTestCase ):
5
+ def test_get_uv_loop_t_ptr (self ):
6
+ loop = self .new_loop ()
7
+ cap1 = loop .get_uv_loop_t_ptr ()
8
+ cap2 = loop .get_uv_loop_t_ptr ()
9
+ cap3 = self .new_loop ().get_uv_loop_t_ptr ()
10
+
11
+ import pyximport
12
+
13
+ pyximport .install ()
14
+
15
+ from tests import cython_helper
16
+
17
+ self .assertTrue (cython_helper .capsule_equals (cap1 , cap2 ))
18
+ self .assertFalse (cython_helper .capsule_equals (cap1 , cap3 ))
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ from cpython cimport (
38
38
PyBytes_AsStringAndSize,
39
39
Py_SIZE, PyBytes_AS_STRING, PyBUF_WRITABLE
40
40
)
41
+ from cpython.pycapsule cimport PyCapsule_New
41
42
42
43
from . import _noop
43
44
@@ -3180,6 +3181,10 @@ cdef class Loop:
3180
3181
except Exception as ex:
3181
3182
self .call_soon_threadsafe(future.set_exception, ex)
3182
3183
3184
+ # Expose pointer for integration with other C-extensions
3185
+ def get_uv_loop_t_ptr (self ):
3186
+ return PyCapsule_New(< void * > self .uvloop, NULL , NULL )
3187
+
3183
3188
3184
3189
cdef void __loop_alloc_buffer(uv.uv_handle_t* uvhandle,
3185
3190
size_t suggested_size,
You can’t perform that action at this time.
0 commit comments