diff options
| author | Victor Stinner <vstinner@python.org> | 2020-04-08 01:13:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-08 01:13:53 +0200 |
| commit | ef5c615f5ae72c4f6979159c94da46afefbfab9a (patch) | |
| tree | 85213408d6eaa43d1bd6c013f5e1cb0d921534be /Objects/abstract.c | |
| parent | 9205520d8c43488696d66cbdd9aefbb21871c508 (diff) | |
| download | cpython-git-ef5c615f5ae72c4f6979159c94da46afefbfab9a.tar.gz | |
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/abstract.c')
| -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 e975edd7c5..49a38d8f6e 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. */ |
