| 568 | // gh-105927 added PyWeakref_GetRef() to Python 3.13.0a1 |
| 569 | #if PY_VERSION_HEX < 0x030D0000 |
| 570 | static 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 |
nothing calls this directly
no outgoing calls
no test coverage detected