1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(_weakref_getweakrefcount__doc__,
6 "getweakrefcount($module, object, /)\n"
7 "--\n"
8 "\n"
9 "Return the number of weak references to \'object\'.");
10 
11 #define _WEAKREF_GETWEAKREFCOUNT_METHODDEF    \
12     {"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__},
13 
14 static Py_ssize_t
15 _weakref_getweakrefcount_impl(PyObject *module, PyObject *object);
16 
17 static PyObject *
_weakref_getweakrefcount(PyObject * module,PyObject * object)18 _weakref_getweakrefcount(PyObject *module, PyObject *object)
19 {
20     PyObject *return_value = NULL;
21     Py_ssize_t _return_value;
22 
23     _return_value = _weakref_getweakrefcount_impl(module, object);
24     if ((_return_value == -1) && PyErr_Occurred()) {
25         goto exit;
26     }
27     return_value = PyLong_FromSsize_t(_return_value);
28 
29 exit:
30     return return_value;
31 }
32 
33 PyDoc_STRVAR(_weakref__remove_dead_weakref__doc__,
34 "_remove_dead_weakref($module, dct, key, /)\n"
35 "--\n"
36 "\n"
37 "Atomically remove key from dict if it points to a dead weakref.");
38 
39 #define _WEAKREF__REMOVE_DEAD_WEAKREF_METHODDEF    \
40     {"_remove_dead_weakref", (PyCFunction)(void(*)(void))_weakref__remove_dead_weakref, METH_FASTCALL, _weakref__remove_dead_weakref__doc__},
41 
42 static PyObject *
43 _weakref__remove_dead_weakref_impl(PyObject *module, PyObject *dct,
44                                    PyObject *key);
45 
46 static PyObject *
_weakref__remove_dead_weakref(PyObject * module,PyObject * const * args,Py_ssize_t nargs)47 _weakref__remove_dead_weakref(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
48 {
49     PyObject *return_value = NULL;
50     PyObject *dct;
51     PyObject *key;
52 
53     if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) {
54         goto exit;
55     }
56     if (!PyDict_Check(args[0])) {
57         _PyArg_BadArgument("_remove_dead_weakref", "argument 1", "dict", args[0]);
58         goto exit;
59     }
60     dct = args[0];
61     key = args[1];
62     return_value = _weakref__remove_dead_weakref_impl(module, dct, key);
63 
64 exit:
65     return return_value;
66 }
67 /*[clinic end generated code: output=c543dc2cd6ece975 input=a9049054013a1b77]*/
68