Home | History | Annotate | Download | only in clinic
      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 *
     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)_weakref__remove_dead_weakref, METH_VARARGS, _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 *
     47 _weakref__remove_dead_weakref(PyObject *module, PyObject *args)
     48 {
     49     PyObject *return_value = NULL;
     50     PyObject *dct;
     51     PyObject *key;
     52 
     53     if (!PyArg_ParseTuple(args, "O!O:_remove_dead_weakref",
     54         &PyDict_Type, &dct, &key)) {
     55         goto exit;
     56     }
     57     return_value = _weakref__remove_dead_weakref_impl(module, dct, key);
     58 
     59 exit:
     60     return return_value;
     61 }
     62 /*[clinic end generated code: output=e860dd818a44bc9b input=a9049054013a1b77]*/
     63