◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Upgrade Operations
pythoncapi_compat.h functions
=============================

Some functions related to frame objects are not available on PyPy.

Python 3.10
-----------
Expand Up @@ -207,6 +207,12 @@ PyThreadState
PyInterpreterState* PyThreadState_GetInterpreter(PyThreadState *tstate);
// Availability: Python 3.7. Not available on PyPy.
uint64_t PyThreadState_GetID(PyThreadState *tstate);

PyInterpreterState
^^^^^^^^^^^^^^^^^^
Expand Up @@ -337,6 +343,8 @@ Links
Changelog
=========

* 2021-04-09: Add Py_Is(), Py_IsNone(), Py_IsTrue(), Py_IsFalse() functions.
* 2021-04-01:

Expand Down
41 changes: 41 additions & 0 deletions pythoncapi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,47 @@ PyThreadState_GetID(PyThreadState *tstate)
}
#endif


// bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
#if PY_VERSION_HEX < 0x030900A1
Expand Down
18 changes: 13 additions & 5 deletions tests/test_pythoncapi_compat_cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#endif

// Ignore reference count checks on PyPy
#if !defined(PYPY_VERSION)
# define CHECK_REFCNT
#endif

Expand Down Expand Up @@ -149,7 +149,7 @@ test_steal_ref(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
}


#if !defined(PYPY_VERSION)
static PyObject *
test_frame(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
{
Expand Down Expand Up @@ -214,7 +214,7 @@ test_thread_state(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
PyInterpreterState *interp = PyThreadState_GetInterpreter(tstate);
assert(interp != NULL);

#if !defined(PYPY_VERSION)
// test PyThreadState_GetFrame()
PyFrameObject *frame = PyThreadState_GetFrame(tstate);
if (frame != NULL) {
Expand All @@ -228,6 +228,14 @@ test_thread_state(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
assert(id > 0);
#endif

Py_RETURN_NONE;
}

Expand Down Expand Up @@ -283,7 +291,7 @@ test_gc(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
Py_INCREF(Py_None);
PyTuple_SET_ITEM(tuple, 0, Py_None);

#if !defined(PYPY_VERSION)
// test PyObject_GC_IsTracked()
int tracked = PyObject_GC_IsTracked(tuple);
assert(tracked);
Expand Down Expand Up @@ -394,7 +402,7 @@ static struct PyMethodDef methods[] = {
{"test_object", test_object, METH_NOARGS, NULL},
{"test_py_is", test_py_is, METH_NOARGS, NULL},
{"test_steal_ref", test_steal_ref, METH_NOARGS, NULL},
#if !defined(PYPY_VERSION)
{"test_frame", test_frame, METH_NOARGS, NULL},
#endif
{"test_thread_state", test_thread_state, METH_NOARGS, NULL},
Expand Down
Toggle all file notes Toggle all file annotations