diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-07 23:13:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 23:13:53 (GMT) |
commit | ef5c615f5ae72c4f6979159c94da46afefbfab9a (patch) | |
tree | 85213408d6eaa43d1bd6c013f5e1cb0d921534be /Objects | |
parent | 9205520d8c43488696d66cbdd9aefbb21871c508 (diff) | |
download | cpython-ef5c615f5ae72c4f6979159c94da46afefbfab9a.zip cpython-ef5c615f5ae72c4f6979159c94da46afefbfab9a.tar.gz cpython-ef5c615f5ae72c4f6979159c94da46afefbfab9a.tar.bz2 |
bpo-40170: Convert PyObject_CheckBuffer() macro to a function (GH-19376)
Convert PyObject_CheckBuffer() macro to a function to hide
implementation details: the macro accessed directly the
PyTypeObject.tp_as_buffer member.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index e975edd..49a38d8 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -277,6 +277,16 @@ PyObject_DelItemString(PyObject *o, const char *key) return ret; } + +/* Return 1 if the getbuffer function is available, otherwise return 0. */ +int +PyObject_CheckBuffer(PyObject *obj) +{ + PyBufferProcs *tp_as_buffer = Py_TYPE(obj)->tp_as_buffer; + return (tp_as_buffer != NULL && tp_as_buffer->bf_getbuffer != NULL); +} + + /* We release the buffer right after use of this function which could cause issues later on. Don't use these functions in new code. */ |