This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: import a pycapsule object that's attached on many modules
Type: enhancement Stage:
Components: C API Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: yorkie
Priority: normal Keywords:

Created on 2019-12-26 11:14 by yorkie, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg358886 - (view) Author: Yorkie Liu (yorkie) Date: 2019-12-26 11:14
Current PyCapsule's name is corresponding to the `modulename.attrname`, which requires it could be imported in the specified module.

And it's possible to implement a feature which shares the same capsule object between different modules, and supports importing them like this:

```
PyCapsule* cap = PyCapsule_New("foobar");
PyObject_SetAttrString(module1, cap->name);
PyObject_SetAttrString(module2, cap->name);

PyCapsule_Import("module1.foobar", 0);
PyCapsule_Import("module2.foobar", 0);
```
msg358887 - (view) Author: Yorkie Liu (yorkie) Date: 2019-12-26 11:25
Update the example:

```
PyCapsule* cap = PyCapsule_New("foobar");
PyObject_SetAttrString(module1, cap->name, cap);
PyObject_SetAttrString(module2, cap->name, cap);

PyCapsule_Import("module1.foobar", 0);
PyCapsule_Import("module2.foobar", 0);
```
msg359499 - (view) Author: Yorkie Liu (yorkie) Date: 2020-01-07 09:13
Ping Python Team.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83319
2020-01-07 09:13:21yorkiesetresolution: remind ->
messages: + msg359499
2019-12-26 11:25:05yorkiesetresolution: remind
messages: + msg358887
2019-12-26 11:14:01yorkiecreate