Skip to content

Commit

Permalink
unsafe_as_py_object_ptr -> unsafe_py_object_ptr
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua James Venter <[email protected]>
  • Loading branch information
jjvraw committed Oct 5, 2024
1 parent 8f597b0 commit f7eccbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions stdlib/src/python/python.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ struct Python:
var result = cpython.PyModule_AddFunctions(
# Safety: `module` pointer lives long enough because its reference
# argument.
module.unsafe_as_py_object_ptr(),
module.unsafe_py_object_ptr(),
functions,
)

Expand Down Expand Up @@ -326,9 +326,9 @@ struct Python:
var cpython = _get_global_python_itf().cpython()

var result = cpython.PyModule_AddObjectRef(
module.unsafe_as_py_object_ptr(),
module.unsafe_py_object_ptr(),
name.unsafe_cstr_ptr(),
value.unsafe_as_py_object_ptr(),
value.unsafe_py_object_ptr(),
)

if result != 0:
Expand Down
8 changes: 4 additions & 4 deletions stdlib/src/python/python_object.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ struct TypedPythonObject[type_hint: StringLiteral](
# TODO:
# This should have lifetime, or we should do this with a context
# manager, to prevent use after ASAP destruction.
fn unsafe_as_py_object_ptr(self) -> PyObjectPtr:
fn unsafe_py_object_ptr(self) -> PyObjectPtr:
"""Get the underlying PyObject pointer.
Returns:
Expand All @@ -189,7 +189,7 @@ struct TypedPythonObject[type_hint: StringLiteral](
Use-after-free: The caller must take care that `self` outlives the
usage of the pointer returned by this function.
"""
return self._obj.unsafe_as_py_object_ptr()
return self._obj.unsafe_py_object_ptr()

# ===-------------------------------------------------------------------===#
# 'Tuple' Operations
Expand All @@ -210,7 +210,7 @@ struct TypedPythonObject[type_hint: StringLiteral](
var cpython = _get_global_python_itf().cpython()

var item: PyObjectPtr = cpython.PyTuple_GetItem(
self.unsafe_as_py_object_ptr(),
self.unsafe_py_object_ptr(),
pos,
)

Expand Down Expand Up @@ -556,7 +556,7 @@ struct PythonObject(
# Methods
# ===-------------------------------------------------------------------===#

fn unsafe_as_py_object_ptr(self) -> PyObjectPtr:
fn unsafe_py_object_ptr(self) -> PyObjectPtr:
"""Get the underlying PyObject pointer.
Returns:
Expand Down

0 comments on commit f7eccbf

Please sign in to comment.