summaryrefslogtreecommitdiffstats
path: root/Include/abstract.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-09-17 11:23:31 (GMT)
committerGitHub <noreply@github.com>2023-09-17 11:23:31 (GMT)
commitadd16f1a5e4013f97d33cc677dc008e8199f5b11 (patch)
tree2c187adbae2766f942e35780950a526dfe84ff48 /Include/abstract.h
parente57ecf6bbc59f999d27b125ea51b042c24a07bd9 (diff)
downloadcpython-add16f1a5e4013f97d33cc677dc008e8199f5b11.zip
cpython-add16f1a5e4013f97d33cc677dc008e8199f5b11.tar.gz
cpython-add16f1a5e4013f97d33cc677dc008e8199f5b11.tar.bz2
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
Diffstat (limited to 'Include/abstract.h')
-rw-r--r--Include/abstract.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/Include/abstract.h b/Include/abstract.h
index dd91500..bd12a54 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -50,6 +50,25 @@ extern "C" {
This function always succeeds. */
+
+/* Implemented elsewhere:
+
+ int PyObject_HasAttrStringWithError(PyObject *o, const char *attr_name);
+
+ Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise.
+ This is equivalent to the Python expression: hasattr(o,attr_name).
+ Returns -1 on failure. */
+
+
+/* Implemented elsewhere:
+
+ int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name);
+
+ Returns 1 if o has the attribute attr_name, and 0 otherwise.
+ This is equivalent to the Python expression: hasattr(o,attr_name).
+ Returns -1 on failure. */
+
+
/* Implemented elsewhere:
PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
@@ -821,6 +840,18 @@ PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
This function always succeeds. */
PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
+/* Return 1 if the mapping object has the key 'key', and 0 otherwise.
+ This is equivalent to the Python expression: key in o.
+ On failure, return -1. */
+
+PyAPI_FUNC(int) PyMapping_HasKeyWithError(PyObject *o, PyObject *key);
+
+/* Return 1 if the mapping object has the key 'key', and 0 otherwise.
+ This is equivalent to the Python expression: key in o.
+ On failure, return -1. */
+
+PyAPI_FUNC(int) PyMapping_HasKeyStringWithError(PyObject *o, const char *key);
+
/* On success, return a list or tuple of the keys in mapping object 'o'.
On failure, return NULL. */
PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o);