summaryrefslogtreecommitdiffstats
path: root/Objects/weakrefobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-07 08:17:07 (GMT)
committerGitHub <noreply@github.com>2020-02-07 08:17:07 (GMT)
commitd2ec81a8c99796b51fb8c49b77a7fe369863226f (patch)
treed88e7cbe89f65366d5591338fbe59a71192950db /Objects/weakrefobject.c
parentdaa9756cb6395323d6f291efe5c7d7fdc6b2e9d8 (diff)
downloadcpython-d2ec81a8c99796b51fb8c49b77a7fe369863226f.zip
cpython-d2ec81a8c99796b51fb8c49b77a7fe369863226f.tar.gz
cpython-d2ec81a8c99796b51fb8c49b77a7fe369863226f.tar.bz2
bpo-39573: Add Py_SET_TYPE() function (GH-18394)
Add Py_SET_TYPE() function to set the type of an object.
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r--Objects/weakrefobject.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index d104b64..18c737e 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -882,10 +882,12 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
if (result != NULL) {
PyWeakReference *prev;
- if (PyCallable_Check(ob))
- Py_TYPE(result) = &_PyWeakref_CallableProxyType;
- else
- Py_TYPE(result) = &_PyWeakref_ProxyType;
+ if (PyCallable_Check(ob)) {
+ Py_SET_TYPE(result, &_PyWeakref_CallableProxyType);
+ }
+ else {
+ Py_SET_TYPE(result, &_PyWeakref_ProxyType);
+ }
get_basic_refs(*list, &ref, &proxy);
if (callback == NULL) {
if (proxy != NULL) {