/src/Python-3.8.3/Modules/clinic/_weakref.c.h
Line | Count | Source (jump to first uncovered line) |
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 | 0 | { |
20 | 0 | PyObject *return_value = NULL; |
21 | 0 | Py_ssize_t _return_value; |
22 | |
|
23 | 0 | _return_value = _weakref_getweakrefcount_impl(module, object); |
24 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
25 | 0 | goto exit; |
26 | 0 | } |
27 | 0 | return_value = PyLong_FromSsize_t(_return_value); |
28 | |
|
29 | 0 | exit: |
30 | 0 | return return_value; |
31 | 0 | } |
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 * |
47 | | _weakref__remove_dead_weakref(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
48 | 0 | { |
49 | 0 | PyObject *return_value = NULL; |
50 | 0 | PyObject *dct; |
51 | 0 | PyObject *key; |
52 | |
|
53 | 0 | if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) { |
54 | 0 | goto exit; |
55 | 0 | } |
56 | 0 | if (!PyDict_Check(args[0])) { |
57 | 0 | _PyArg_BadArgument("_remove_dead_weakref", "argument 1", "dict", args[0]); |
58 | 0 | goto exit; |
59 | 0 | } |
60 | 0 | dct = args[0]; |
61 | 0 | key = args[1]; |
62 | 0 | return_value = _weakref__remove_dead_weakref_impl(module, dct, key); |
63 | |
|
64 | 0 | exit: |
65 | 0 | return return_value; |
66 | 0 | } |
67 | | /*[clinic end generated code: output=c543dc2cd6ece975 input=a9049054013a1b77]*/ |