Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ctypes so it can work with no dynamic linking builds #110

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pytest_pyodide/_decorator_in_pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
https://github.com/pyodide/pytest-pyodide/issues/43
"""

import ctypes
import pickle
from base64 import b64decode, b64encode
from io import BytesIO
from typing import Any

import pyodide_js

Check warning on line 24 in pytest_pyodide/_decorator_in_pyodide.py

View check run for this annotation

Codecov / codecov/patch

pytest_pyodide/_decorator_in_pyodide.py#L24

Added line #L24 was not covered by tests


def pointer_to_object(ptr: int) -> Any:
"""Interpret ptr as a PyObject* and convert it to the actual Python object.
Expand All @@ -32,7 +33,7 @@
# object: use PyObject_SetItem to assign it to a dictionary.
# ctypes doesn't seem to have an API to do this directly.
temp: dict[int, Any] = {}
ctypes.pythonapi.PyObject_SetItem(id(temp), id(0), ptr)
pyodide_js._module._PyDict_SetItem(id(temp), id(0), ptr)

Check warning on line 36 in pytest_pyodide/_decorator_in_pyodide.py

View check run for this annotation

Codecov / codecov/patch

pytest_pyodide/_decorator_in_pyodide.py#L36

Added line #L36 was not covered by tests
return temp[0]


Expand All @@ -55,7 +56,7 @@
def persistent_id(self, obj: Any) -> Any:
if not isinstance(obj, PyodideHandle):
return None
ctypes.pythonapi.Py_IncRef(obj.ptr)
pyodide_js._module._Py_IncRef(obj.ptr)

Check warning on line 59 in pytest_pyodide/_decorator_in_pyodide.py

View check run for this annotation

Codecov / codecov/patch

pytest_pyodide/_decorator_in_pyodide.py#L59

Added line #L59 was not covered by tests
return ("PyodideHandle", obj.ptr)


Expand Down