MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / PyObject_GetOptionalAttr

Function PyObject_GetOptionalAttr

asyncpg/protocol/record/pythoncapi_compat.h:686–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684// PyObject_GetOptionalAttrString() to Python 3.13.0a1
685#if PY_VERSION_HEX < 0x030D00A1
686static inline int
687PyObject_GetOptionalAttr(PyObject *obj, PyObject *attr_name, PyObject **result)
688{
689 // bpo-32571 added _PyObject_LookupAttr() to Python 3.7.0b1
690#if PY_VERSION_HEX >= 0x030700B1 && !defined(PYPY_VERSION)
691 return _PyObject_LookupAttr(obj, attr_name, result);
692#else
693 *result = PyObject_GetAttr(obj, attr_name);
694 if (*result != NULL) {
695 return 1;
696 }
697 if (!PyErr_Occurred()) {
698 return 0;
699 }
700 if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
701 PyErr_Clear();
702 return 0;
703 }
704 return -1;
705#endif
706}
707
708static inline int
709PyObject_GetOptionalAttrString(PyObject *obj, const char *attr_name, PyObject **result)

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected