mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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()
This commit is contained in:
parent
e57ecf6bbc
commit
add16f1a5e
28 changed files with 330 additions and 111 deletions
|
@ -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);
|
||||
|
|
|
@ -394,6 +394,10 @@ PyAPI_FUNC(int) PyObject_GetOptionalAttrString(PyObject *, const char *, PyObjec
|
|||
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_DelAttr(PyObject *v, PyObject *name);
|
||||
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
|
||||
PyAPI_FUNC(int) PyObject_HasAttrWithError(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_HasAttrStringWithError(PyObject *, const char *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, PyObject *, PyObject *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue