Skip to content

gh-76595: PyCapsule_Import() now imports submodules if needed.#6898

Open
serhiy-storchaka wants to merge 5 commits into
python:mainfrom
serhiy-storchaka:capsule-import-submodules
Open

gh-76595: PyCapsule_Import() now imports submodules if needed.#6898
serhiy-storchaka wants to merge 5 commits into
python:mainfrom
serhiy-storchaka:capsule-import-submodules

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented May 16, 2018

Copy link
Copy Markdown
Member

@encukou

encukou commented May 16, 2018

Copy link
Copy Markdown
Member

Do you plan to add tests, or are you OK leaving that to someone else?

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Currently there are no any tests for PyCapsule. I'm going to write them if possible, but this will take a time.

@encukou

encukou commented May 16, 2018

Copy link
Copy Markdown
Member

I'm asking because writing tests would make a nice task for mentoring someone – but it would take even more time that way.

Comment thread Objects/capsule.c Outdated
if (object) {
PyObject *object2 = PyObject_GetAttrString(object, trace);
Py_DECREF(object);
object = object2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Py_SETREF?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can be used here.

Comment thread Objects/capsule.c Outdated
if (no_block) {
object = PyImport_ImportModuleNoBlock(name_dup);
} else {
object = PyImport_ImportModule(name_dup);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't PyImport_ImportModuleNoBlock and PyImport_ImportModule the same thing now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Comment thread Objects/capsule.c
Py_DECREF(object);
object = object2;
if (object) {
Py_SETREF(object, PyObject_GetAttrString(object, trace));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect error handling here, if PyObject_GetAttrString() fails for whatever reason. It seems like PyImport_ImportModule() is tried on the substring on error.

@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@csabella

Copy link
Copy Markdown
Contributor

@serhiy-storchaka, it looks like this one was close to being merged, so just putting it back on the radar.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 19, 2022
@WillAyd

WillAyd commented Feb 20, 2023

Copy link
Copy Markdown
Contributor

I have a use case for this and would be happy to rebase / take over from @serhiy-storchaka if you don't have the time for it

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Sep 21, 2024
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Dec 15, 2024
@picnixz picnixz changed the title bpo-32414: PyCapsule_Import() now imports submodules if needed. gh-76595: PyCapsule_Import() now imports submodules if needed. Dec 15, 2024
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Feb 27, 2025
@github-actions

github-actions Bot commented Apr 9, 2025

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 9, 2025
NicolasT added a commit to NicolasT/cpython that referenced this pull request May 14, 2025
There's a PR (pythonGH-6898) which changes this behavior (to be less
surprising, I believe), but this seems to have stalled.

See: python#76595
See: python#6898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants