Branch data Line data Source code
1 : : /*[clinic input]
2 : : preserve
3 : : [clinic start generated code]*/
4 : :
5 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 : : # include "pycore_gc.h" // PyGC_Head
7 : : # include "pycore_runtime.h" // _Py_ID()
8 : : #endif
9 : :
10 : :
11 : : static int
12 : : sock_initobj_impl(PySocketSockObject *self, int family, int type, int proto,
13 : : PyObject *fdobj);
14 : :
15 : : static int
16 : 0 : sock_initobj(PyObject *self, PyObject *args, PyObject *kwargs)
17 : : {
18 : 0 : int return_value = -1;
19 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
20 : :
21 : : #define NUM_KEYWORDS 4
22 : : static struct {
23 : : PyGC_Head _this_is_not_used;
24 : : PyObject_VAR_HEAD
25 : : PyObject *ob_item[NUM_KEYWORDS];
26 : : } _kwtuple = {
27 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
28 : : .ob_item = { &_Py_ID(family), &_Py_ID(type), &_Py_ID(proto), &_Py_ID(fileno), },
29 : : };
30 : : #undef NUM_KEYWORDS
31 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
32 : :
33 : : #else // !Py_BUILD_CORE
34 : : # define KWTUPLE NULL
35 : : #endif // !Py_BUILD_CORE
36 : :
37 : : static const char * const _keywords[] = {"family", "type", "proto", "fileno", NULL};
38 : : static _PyArg_Parser _parser = {
39 : : .keywords = _keywords,
40 : : .fname = "socket",
41 : : .kwtuple = KWTUPLE,
42 : : };
43 : : #undef KWTUPLE
44 : : PyObject *argsbuf[4];
45 : : PyObject * const *fastargs;
46 : 0 : Py_ssize_t nargs = PyTuple_GET_SIZE(args);
47 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
48 : 0 : int family = -1;
49 : 0 : int type = -1;
50 : 0 : int proto = -1;
51 : 0 : PyObject *fdobj = NULL;
52 : :
53 [ # # # # : 0 : fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 4, 0, argsbuf);
# # # # ]
54 [ # # ]: 0 : if (!fastargs) {
55 : 0 : goto exit;
56 : : }
57 [ # # ]: 0 : if (!noptargs) {
58 : 0 : goto skip_optional_pos;
59 : : }
60 [ # # ]: 0 : if (fastargs[0]) {
61 : 0 : family = _PyLong_AsInt(fastargs[0]);
62 [ # # # # ]: 0 : if (family == -1 && PyErr_Occurred()) {
63 : 0 : goto exit;
64 : : }
65 [ # # ]: 0 : if (!--noptargs) {
66 : 0 : goto skip_optional_pos;
67 : : }
68 : : }
69 [ # # ]: 0 : if (fastargs[1]) {
70 : 0 : type = _PyLong_AsInt(fastargs[1]);
71 [ # # # # ]: 0 : if (type == -1 && PyErr_Occurred()) {
72 : 0 : goto exit;
73 : : }
74 [ # # ]: 0 : if (!--noptargs) {
75 : 0 : goto skip_optional_pos;
76 : : }
77 : : }
78 [ # # ]: 0 : if (fastargs[2]) {
79 : 0 : proto = _PyLong_AsInt(fastargs[2]);
80 [ # # # # ]: 0 : if (proto == -1 && PyErr_Occurred()) {
81 : 0 : goto exit;
82 : : }
83 [ # # ]: 0 : if (!--noptargs) {
84 : 0 : goto skip_optional_pos;
85 : : }
86 : : }
87 : 0 : fdobj = fastargs[3];
88 : 0 : skip_optional_pos:
89 : 0 : return_value = sock_initobj_impl((PySocketSockObject *)self, family, type, proto, fdobj);
90 : :
91 : 0 : exit:
92 : 0 : return return_value;
93 : : }
94 : : /*[clinic end generated code: output=987155ac4b48a198 input=a9049054013a1b77]*/
|