-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose uv_loop_t pointer for integration with other C-extensions (#310)
Co-authored-by: Fantix King <fantix.king@gmail.com>
- Loading branch information
1 parent
a130375
commit b332eb8
Showing
4 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from cpython.pycapsule cimport PyCapsule_GetPointer | ||
|
||
|
||
def capsule_equals(cap1, cap2): | ||
return PyCapsule_GetPointer(cap1, NULL) == PyCapsule_GetPointer(cap2, NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from uvloop import _testbase as tb | ||
|
||
|
||
class Test_UV_Pointers(tb.UVTestCase): | ||
def test_get_uv_loop_t_ptr(self): | ||
loop = self.new_loop() | ||
cap1 = loop.get_uv_loop_t_ptr() | ||
cap2 = loop.get_uv_loop_t_ptr() | ||
cap3 = self.new_loop().get_uv_loop_t_ptr() | ||
|
||
import pyximport | ||
|
||
pyximport.install() | ||
|
||
from tests import cython_helper | ||
|
||
self.assertTrue(cython_helper.capsule_equals(cap1, cap2)) | ||
self.assertFalse(cython_helper.capsule_equals(cap1, cap3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters