Skip to content
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

gh-117764: Fix and add signatures for many builtins #117769

Merged
merged 3 commits into from
Apr 12, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Apr 11, 2024

Comment on lines +3258 to +3260
PyDoc_STRVAR(memory_exit_doc,
"__exit__($self, /, *exc_info)\n--\n\n"
"Release the underlying buffer exposed by the memoryview object.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
PyDoc_STRVAR(memory_exit_doc,
"__exit__($self, /, *exc_info)\n--\n\n"
"Release the underlying buffer exposed by the memoryview object.");
PyDoc_STRVAR(memory_enter_doc,
"__enter__($self)\n--\n\n"
"Check the underlying buffer has not been released.");
PyDoc_STRVAR(memory_exit_doc,
"__exit__($self, /, *exc_info)\n--\n\n"
"Release the underlying buffer exposed by the memoryview object.");

(maybe the signature for enter is not correct, it returns a reference to itself)

Copy link
Member Author

Choose a reason for hiding this comment

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

It is rather the side effect.

Copy link
Member Author

Choose a reason for hiding this comment

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

I left this for future. The __enter__ methods either acquire the resource, in which case it should be explicitly documented, or do not have a side effect, in which case they do not need a docstring. I am not sure what is closer to this case.

@@ -3283,7 +3286,7 @@ static PyMethodDef memory_methods[] = {
MEMORYVIEW_TOREADONLY_METHODDEF
MEMORYVIEW__FROM_FLAGS_METHODDEF
{"__enter__", memory_enter, METH_NOARGS, NULL},
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{"__enter__", memory_enter, METH_NOARGS, NULL},
{"__enter__", memory_enter, METH_NOARGS, memory_enter_doc},

Objects/namespaceobject.c Show resolved Hide resolved
Objects/genericaliasobject.c Show resolved Hide resolved
Objects/descrobject.c Outdated Show resolved Hide resolved
serhiy-storchaka and others added 2 commits April 12, 2024 00:25
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
@serhiy-storchaka serhiy-storchaka merged commit 3a8c1ca into python:main Apr 12, 2024
34 checks passed
@serhiy-storchaka serhiy-storchaka deleted the builtin-signatures2 branch April 12, 2024 10:56
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
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.

3 participants