From 8f11f7ec76dbbcd9547dc52bd96a5eae3a09f4b4 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 17 Dec 2024 10:11:46 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Victor Stinner --- Doc/c-api/weakref.rst | 2 +- Objects/weakrefobject.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/weakref.rst b/Doc/c-api/weakref.rst index 00ed977dd0e58d..c3c6cf413dcef5 100644 --- a/Doc/c-api/weakref.rst +++ b/Doc/c-api/weakref.rst @@ -90,7 +90,7 @@ as much as it can. .. c:function:: int PyWeakref_IsDead(PyObject *ref) - Test if a weak reference, *ref*, is dead. Returns 1 if the reference is + Test if the weak reference *ref* is dead. Returns 1 if the reference is dead, 0 if it is alive, and -1 with an error set if *ref* is not a weak reference object. diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index d9c742eac053e3..0ee64ed70a63cd 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -940,7 +940,7 @@ PyWeakref_IsDead(PyObject *ref) return -1; } if (!PyWeakref_Check(ref)) { - PyErr_SetString(PyExc_TypeError, "expected a weakref"); + PyErr_Format(PyExc_TypeError, "expected a weakref, got %T", ref); return -1; } return _PyWeakref_IS_DEAD(ref);