/src/cpython/Objects/clinic/picklebufobject.c.h
Line | Count | Source |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #include "pycore_modsupport.h" // _PyArg_CheckPositional() |
6 | | |
7 | | PyDoc_STRVAR(picklebuf_new__doc__, |
8 | | "PickleBuffer(buffer, /)\n" |
9 | | "--\n" |
10 | | "\n" |
11 | | "Wrapper for potentially out-of-band buffers."); |
12 | | |
13 | | static PyObject * |
14 | | picklebuf_new_impl(PyTypeObject *type, PyObject *base); |
15 | | |
16 | | static PyObject * |
17 | | picklebuf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
18 | 0 | { |
19 | 0 | PyObject *return_value = NULL; |
20 | 0 | PyTypeObject *base_tp = &PyPickleBuffer_Type; |
21 | 0 | PyObject *base; |
22 | |
|
23 | 0 | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
24 | 0 | !_PyArg_NoKeywords("PickleBuffer", kwargs)) { |
25 | 0 | goto exit; |
26 | 0 | } |
27 | 0 | if (!_PyArg_CheckPositional("PickleBuffer", PyTuple_GET_SIZE(args), 1, 1)) { |
28 | 0 | goto exit; |
29 | 0 | } |
30 | 0 | base = PyTuple_GET_ITEM(args, 0); |
31 | 0 | return_value = picklebuf_new_impl(type, base); |
32 | |
|
33 | 0 | exit: |
34 | 0 | return return_value; |
35 | 0 | } |
36 | | |
37 | | static PyObject * |
38 | | picklebuf_vectorcall(PyObject *type, PyObject *const *args, |
39 | | size_t nargsf, PyObject *kwnames) |
40 | 0 | { |
41 | 0 | PyObject *return_value = NULL; |
42 | 0 | Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); |
43 | 0 | PyObject *base; |
44 | |
|
45 | 0 | assert(_PyType_CAST(type)->tp_new == picklebuf_new); |
46 | | /* Make sure the type object is immutable: the generated |
47 | | * vectorcall doesn't deal e.g. with users reassigning __init__. */ |
48 | 0 | assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); |
49 | 0 | if (!_PyArg_NoKwnames("PickleBuffer", kwnames)) { |
50 | 0 | goto exit; |
51 | 0 | } |
52 | 0 | if (!_PyArg_CheckPositional("PickleBuffer", nargs, 1, 1)) { |
53 | 0 | goto exit; |
54 | 0 | } |
55 | 0 | base = args[0]; |
56 | 0 | return_value = picklebuf_new_impl(_PyType_CAST(type), base); |
57 | |
|
58 | 0 | exit: |
59 | 0 | return return_value; |
60 | 0 | } |
61 | | /*[clinic end generated code: output=4c32a9c4ea5b9bfe input=a9049054013a1b77]*/ |