/src/Python-3.8.3/Python/clinic/_warnings.c.h
Line  | Count  | Source  | 
1  |  | /*[clinic input]  | 
2  |  | preserve  | 
3  |  | [clinic start generated code]*/  | 
4  |  |  | 
5  |  | PyDoc_STRVAR(warnings_warn__doc__,  | 
6  |  | "warn($module, /, message, category=None, stacklevel=1, source=None)\n"  | 
7  |  | "--\n"  | 
8  |  | "\n"  | 
9  |  | "Issue a warning, or maybe ignore it or raise an exception.");  | 
10  |  |  | 
11  |  | #define WARNINGS_WARN_METHODDEF    \  | 
12  |  |     {"warn", (PyCFunction)(void(*)(void))warnings_warn, METH_FASTCALL|METH_KEYWORDS, warnings_warn__doc__}, | 
13  |  |  | 
14  |  | static PyObject *  | 
15  |  | warnings_warn_impl(PyObject *module, PyObject *message, PyObject *category,  | 
16  |  |                    Py_ssize_t stacklevel, PyObject *source);  | 
17  |  |  | 
18  |  | static PyObject *  | 
19  |  | warnings_warn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)  | 
20  | 0  | { | 
21  | 0  |     PyObject *return_value = NULL;  | 
22  | 0  |     static const char * const _keywords[] = {"message", "category", "stacklevel", "source", NULL}; | 
23  | 0  |     static _PyArg_Parser _parser = {NULL, _keywords, "warn", 0}; | 
24  | 0  |     PyObject *argsbuf[4];  | 
25  | 0  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;  | 
26  | 0  |     PyObject *message;  | 
27  | 0  |     PyObject *category = Py_None;  | 
28  | 0  |     Py_ssize_t stacklevel = 1;  | 
29  | 0  |     PyObject *source = Py_None;  | 
30  |  | 
  | 
31  | 0  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf);  | 
32  | 0  |     if (!args) { | 
33  | 0  |         goto exit;  | 
34  | 0  |     }  | 
35  | 0  |     message = args[0];  | 
36  | 0  |     if (!noptargs) { | 
37  | 0  |         goto skip_optional_pos;  | 
38  | 0  |     }  | 
39  | 0  |     if (args[1]) { | 
40  | 0  |         category = args[1];  | 
41  | 0  |         if (!--noptargs) { | 
42  | 0  |             goto skip_optional_pos;  | 
43  | 0  |         }  | 
44  | 0  |     }  | 
45  | 0  |     if (args[2]) { | 
46  | 0  |         if (PyFloat_Check(args[2])) { | 
47  | 0  |             PyErr_SetString(PyExc_TypeError,  | 
48  | 0  |                             "integer argument expected, got float" );  | 
49  | 0  |             goto exit;  | 
50  | 0  |         }  | 
51  | 0  |         { | 
52  | 0  |             Py_ssize_t ival = -1;  | 
53  | 0  |             PyObject *iobj = PyNumber_Index(args[2]);  | 
54  | 0  |             if (iobj != NULL) { | 
55  | 0  |                 ival = PyLong_AsSsize_t(iobj);  | 
56  | 0  |                 Py_DECREF(iobj);  | 
57  | 0  |             }  | 
58  | 0  |             if (ival == -1 && PyErr_Occurred()) { | 
59  | 0  |                 goto exit;  | 
60  | 0  |             }  | 
61  | 0  |             stacklevel = ival;  | 
62  | 0  |         }  | 
63  | 0  |         if (!--noptargs) { | 
64  | 0  |             goto skip_optional_pos;  | 
65  | 0  |         }  | 
66  | 0  |     }  | 
67  | 0  |     source = args[3];  | 
68  | 0  | skip_optional_pos:  | 
69  | 0  |     return_value = warnings_warn_impl(module, message, category, stacklevel, source);  | 
70  |  | 
  | 
71  | 0  | exit:  | 
72  | 0  |     return return_value;  | 
73  | 0  | }  | 
74  |  | /*[clinic end generated code: output=b7bb54c73b5433ec input=a9049054013a1b77]*/  |