Skip to content

Commit 7265e1e

Browse files
committed
Add withPyObject for symmetry
1 parent 67e11b0 commit 7265e1e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Python/Internal/Types.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
module Python.Internal.Types
1010
( -- * Data type
1111
PyObject(..)
12+
, withPyObject
1213
, unsafeWithPyObject
1314
, PyThreadState
1415
, PyError(..)
@@ -64,6 +65,9 @@ data PyThreadState
6465
newtype PyObject = PyObject (ForeignPtr PyObject)
6566
deriving stock Show
6667

68+
withPyObject :: forall a. PyObject -> (Ptr PyObject -> Py a) -> Py a
69+
withPyObject = coerce (withForeignPtr @PyObject @a)
70+
6771
unsafeWithPyObject :: forall a. PyObject -> (Ptr PyObject -> Py a) -> Py a
6872
unsafeWithPyObject = coerce (unsafeWithForeignPtr @PyObject @a)
6973

0 commit comments

Comments
 (0)