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

Function PyWeakref_GetRef

asyncpg/protocol/record/pythoncapi_compat.h:570–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568// gh-105927 added PyWeakref_GetRef() to Python 3.13.0a1
569#if PY_VERSION_HEX < 0x030D0000
570static inline int PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
571{
572 PyObject *obj;
573 if (ref != NULL && !PyWeakref_Check(ref)) {
574 *pobj = NULL;
575 PyErr_SetString(PyExc_TypeError, "expected a weakref");
576 return -1;
577 }
578 obj = PyWeakref_GetObject(ref);
579 if (obj == NULL) {
580 // SystemError if ref is NULL
581 *pobj = NULL;
582 return -1;
583 }
584 if (obj == Py_None) {
585 *pobj = NULL;
586 return 0;
587 }
588 *pobj = Py_NewRef(obj);
589 return 1;
590}
591#endif
592
593

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected