Skip to content

bpo-33829: provide new object protocol helper for C API#7625

Closed
brgl wants to merge 1 commit intopython:masterfrom
brgl:new-object-protocol-function
Closed

bpo-33829: provide new object protocol helper for C API#7625
brgl wants to merge 1 commit intopython:masterfrom
brgl:new-object-protocol-function

Conversation

@brgl
Copy link
Copy Markdown

@brgl brgl commented Jun 11, 2018

If we want to call an object's method from C code and pass it the args
and kwargs tuples unchanged, we need to first retrieve the callable
object using PyObject_GetAttrString(), then call it using
PyObject_Call().

This patch proposes to wrap the two calls in a new helper.

https://bugs.python.org/issue33829

@the-knights-who-say-ni
Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again for your contribution, we look forward to reviewing it!

If we want to call an object's method from C code and pass it the args
and kwargs tuples unchanged, we need to first retrieve the callable
object using PyObject_GetAttrString(), then call it using
PyObject_Call().

This patch proposes to wrap the two calls in a new helper.
@brgl brgl force-pushed the new-object-protocol-function branch from 27e2c7a to ffc3e25 Compare June 11, 2018 10:05
@brgl
Copy link
Copy Markdown
Author

brgl commented Jun 11, 2018

CLA is now signed.

Comment thread Objects/call.c
{
PyObject *callable, *retval;

if (obj == NULL)
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.

Please, use braces as indicated in pep 7: https://www.python.org/dev/peps/pep-0007/

Comment thread Objects/call.c
return null_error();

callable = PyObject_GetAttrString(obj, name);
if (callable == NULL)
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.

Se comment above.

@pablogsal
Copy link
Copy Markdown
Member

Also, it seems that core developers are not sure that this change is needed. Can you discuss with them in the issue? Thanks! :)

@csabella
Copy link
Copy Markdown
Contributor

Closing this pull request as the bug tracker issue was rejected.

@csabella csabella closed this Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants