[issue36203] PyWeakref_NewRef docs are misleading

Windson Yang <wiwindson@outlook.com> added the comment: Yes, Maxwell. I guess the docs are misleading, the code locate in https://github.com/python/cpython/blob/master/Objects/weakrefobject.c#L748 if (callback == Py_None) callback = NULL; if (callback == NULL) /* return existing weak reference if it exists */ result = ref; if (result != NULL) Py_INCREF(result); else { ... } However, I'm not sure we should fix the docs or the code here. ---------- nosy: +Windson Yang _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36203> _______________________________________

Maxwell Bernstein <tekk.nolagi@gmail.com> added the comment: NewProxy checks if it's callable, so I suppose the code should be fixed. On Wed, Mar 6, 2019, 03:32 Windson Yang <report@bugs.python.org> wrote:
Windson Yang <wiwindson@outlook.com> added the comment:
Yes, Maxwell. I guess the docs are misleading, the code locate in https://github.com/python/cpython/blob/master/Objects/weakrefobject.c#L748
if (callback == Py_None) callback = NULL; if (callback == NULL) /* return existing weak reference if it exists */ result = ref; if (result != NULL) Py_INCREF(result); else { ... }
However, I'm not sure we should fix the docs or the code here.
---------- nosy: +Windson Yang
_______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36203> _______________________________________
---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36203> _______________________________________
participants (2)
-
Maxwell Bernstein
-
Windson Yang