Skip to content

Commit f8d0fbb

Browse files
readd unwrap macro
1 parent 033be36 commit f8d0fbb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Objects/weakrefobject.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,21 @@ _proxy_unwrap(PyObject **op, int *did_incref)
557557
return 1;
558558
}
559559

560+
/* If a parameter is a proxy, check that it is still "live" and wrap it,
561+
* replacing the original value with the raw object. Raises ReferenceError
562+
* if the param is a dead proxy.
563+
*/
564+
#define UNWRAP(o) \
565+
if (PyWeakref_CheckProxy(o)) { \
566+
o = _PyWeakref_GET_REF(o); \
567+
if (!proxy_check_ref(o)) { \
568+
return NULL; \
569+
} \
570+
} \
571+
else { \
572+
Py_INCREF(o); \
573+
}
574+
560575
#define WRAP_UNARY(method, generic) \
561576
static PyObject * \
562577
method(PyObject *proxy) { \

0 commit comments

Comments
 (0)