Skip to content

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

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:builtin-signatures2
Apr 12, 2024
Merged

gh-117764: Fix and add signatures for many builtins#117769
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:builtin-signatures2

Conversation

@serhiy-storchaka

@serhiy-storchakaserhiy-storchaka commented Apr 11, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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},

Comment threadObjects/namespaceobject.c
Comment threadObjects/genericaliasobject.c
Comment threadObjects/descrobject.c Outdated
serhiy-storchakaand 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:mainApr 12, 2024
@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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@serhiy-storchaka@eendebakpt@erlend-aasland