Skip to content

bpo-45855: document that no_block has no use anymore in PyCapsule_Import #29665

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

Merged
merged 1 commit into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
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 Doc/c-api/capsule.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ Refer to :ref:`using-capsules` for more information on using these objects.
Import a pointer to a C object from a capsule attribute in a module. The
*name* parameter should specify the full name to the attribute, as in
``module.attribute``. The *name* stored in the capsule must match this
string exactly. If *no_block* is true, import the module without blocking
(using :c:func:`PyImport_ImportModuleNoBlock`). If *no_block* is false,
import the module conventionally (using :c:func:`PyImport_ImportModule`).
string exactly.

Return the capsule's internal *pointer* on success. On failure, set an
exception and return ``NULL``.

.. versionchanged:: 3.3
*no_block* has no effect anymore.


.. c:function:: int PyCapsule_IsValid(PyObject *capsule, const char *name)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Document that the *no_block* argument to :c:func:`PyCapsule_Import` is a
no-op now.
10 changes: 3 additions & 7 deletions Objects/capsule.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,9 @@ PyCapsule_Import(const char *name, int no_block)
}

if (object == NULL) {
if (no_block) {
object = PyImport_ImportModule(trace);
} else {
object = PyImport_ImportModule(trace);
if (!object) {
PyErr_Format(PyExc_ImportError, "PyCapsule_Import could not import module \"%s\"", trace);
}
object = PyImport_ImportModule(trace);
if (!object) {
PyErr_Format(PyExc_ImportError, "PyCapsule_Import could not import module \"%s\"", trace);
}
} else {
PyObject *object2 = PyObject_GetAttrString(object, trace);
Expand Down