MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / _PyArg_CheckPositional

Function _PyArg_CheckPositional

include/pyshim.hh:47–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 */
46#if PY_VERSION_HEX >= 0x030d0000 // Python version is greater than 3.13
47inline int _PyArg_CheckPositional(const char *name, Py_ssize_t nargs, Py_ssize_t min, Py_ssize_t max) {
48 if (!name) { // _PyArg_CheckPositional may also be when unpacking a tuple
49 name = "unpacked tuple"; // https://github.com/python/cpython/blob/v3.13.0rc1/Python/getargs.c#L2746
50 }
51
52 if (nargs < min) {
53 PyErr_Format(
54 PyExc_TypeError,
55 "%.200s expected %s%zd argument%s, got %zd",
56 name, (min == max ? "" : "at least "), min, min == 1 ? "" : "s", nargs);
57 return 0;
58 }
59
60 if (nargs == 0) {
61 return 1;
62 }
63
64 if (nargs > max) {
65 PyErr_Format(
66 PyExc_TypeError,
67 "%.200s expected %s%zd argument%s, got %zd",
68 name, (min == max ? "" : "at most "), max, max == 1 ? "" : "s", nargs);
69 return 0;
70 }
71
72 return 1;
73}
74#endif
75
76/**

Callers 6

JSArrayProxy_insertMethod · 0.85
JSArrayProxy_popMethod · 0.85
JSArrayProxy_indexMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected