Skip to content

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.

MEMORYVIEW_CAST_METHODDEF
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},

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