Skip to content

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

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

serhiy-storchaka
Copy link
Member

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

@encukou
Copy link
Member

encukou commented May 16, 2018

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

@serhiy-storchaka
Copy link
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
Copy link
Member

encukou commented May 16, 2018

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

}
}
} else {
if (object) {
PyObject *object2 = PyObject_GetAttrString(object, trace);
Py_DECREF(object);
object = object2;
Copy link
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
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.

if (no_block) {
object = PyImport_ImportModuleNoBlock(name_dup);
} else {
object = PyImport_ImportModule(name_dup);
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Good point!

Py_DECREF(object);
object = object2;
if (object) {
Py_SETREF(object, PyObject_GetAttrString(object, trace));
Copy link
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

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

@csabella
Copy link
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

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
Copy link
Contributor

WillAyd commented Feb 20, 2023

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
Copy link

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
Copy link

github-actions bot commented Apr 9, 2025

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
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