summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/config-highlight.def
blob: aaa2b57a7f6d851b00e6c5f425d4351627a7f164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# IDLE reads several config files to determine user preferences.  This
# file is the default config file for idle highlight theme settings.

[IDLE Classic]
normal-foreground= #000000
normal-background= #ffffff
keyword-foreground= #ff7700
keyword-background= #ffffff
builtin-foreground= #900090
builtin-background= #ffffff
comment-foreground= #dd0000
comment-background= #ffffff
string-foreground= #00aa00
string-background= #ffffff
definition-foreground= #0000ff
definition-background= #ffffff
hilite-foreground= #000000
hilite-background= gray
break-foreground= black
break-background= #ffff55
hit-foreground= #ffffff
hit-background= #000000
error-foreground= #000000
error-background= #ff7777
#cursor (only foreground can be set, restart IDLE)
cursor-foreground= black
#shell window
stdout-foreground= blue
stdout-background= #ffffff
stderr-foreground= red
stderr-background= #ffffff
console-foreground= #770000
console-background= #ffffff
context-foreground= #000000
context-background= lightgray

[IDLE New]
normal-foreground= #000000
normal-background= #ffffff
keyword-foreground= #ff7700
keyword-background= #ffffff
builtin-foreground= #900090
builtin-background= #ffffff
comment-foreground= #dd0000
comment-background= #ffffff
string-foreground= #00aa00
string-background= #ffffff
definition-foreground= #0000ff
definition-background= #ffffff
hilite-foreground= #000000
hilite-background= gray
break-foreground= black
break-background= #ffff55
hit-foreground= #ffffff
hit-background= #000000
error-foreground= #000000
error-background= #ff7777
#cursor (only foreground can be set, restart IDLE)
cursor-foreground= black
#shell window
stdout-foreground= blue
stdout-background= #ffffff
stderr-foreground= red
stderr-background= #ffffff
console-foreground= #770000
console-background= #ffffff
context-foreground= #000000
context-background= lightgray

[IDLE Dark]
comment-foreground = #dd0000
console-foreground = #ff4d4d
error-foreground = #FFFFFF
hilite-background = #7e7e7e
string-foreground = #02ff02
stderr-background = #002240
stderr-foreground = #ffb3b3
console-background = #002240
hit-background = #fbfbfb
string-background = #002240
normal-background = #002240
hilite-foreground = #FFFFFF
keyword-foreground = #ff8000
error-background = #c86464
keyword-background = #002240
builtin-background = #002240
break-background = #808000
builtin-foreground = #ff00ff
definition-foreground = #5e5eff
stdout-foreground = #c2d1fa
definition-background = #002240
normal-foreground = #FFFFFF
cursor-foreground = #ffffff
stdout-background = #002240
hit-foreground = #002240
comment-background = #002240
break-foreground = #FFFFFF
context-foreground= #ffffff
context-background= #454545
-r--r--Modules/clinic/_weakref.c.h11
-rw-r--r--Modules/clinic/arraymodule.c.h98
-rw-r--r--Modules/clinic/audioop.c.h617
-rw-r--r--Modules/clinic/binascii.c.h54
-rw-r--r--Modules/clinic/cmathmodule.c.h25
-rw-r--r--Modules/clinic/fcntlmodule.c.h100
-rw-r--r--Modules/clinic/itertoolsmodule.c.h46
-rw-r--r--Modules/clinic/mathmodule.c.h32
-rw-r--r--Modules/clinic/posixmodule.c.h527
-rw-r--r--Modules/clinic/pwdmodule.c.h4
-rw-r--r--Modules/clinic/pyexpat.c.h70
-rw-r--r--Modules/clinic/resource.c.h15
-rw-r--r--Modules/clinic/selectmodule.c.h68
-rw-r--r--Modules/clinic/signalmodule.c.h93
-rw-r--r--Modules/clinic/spwdmodule.c.h4
-rw-r--r--Modules/clinic/symtablemodule.c.h34
-rw-r--r--Modules/clinic/unicodedata.c.h144
-rw-r--r--Modules/clinic/zlibmodule.c.h76
-rw-r--r--Objects/clinic/bytearrayobject.c.h122
-rw-r--r--Objects/clinic/bytesobject.c.h63
-rw-r--r--Objects/clinic/floatobject.c.h35
-rw-r--r--Objects/clinic/listobject.c.h64
-rw-r--r--Objects/clinic/longobject.c.h4
-rw-r--r--Objects/clinic/tupleobject.c.h19
-rw-r--r--Objects/clinic/typeobject.c.h4
-rw-r--r--Objects/clinic/unicodeobject.c.h152
-rw-r--r--Objects/stringlib/clinic/transmogrify.h.h104
-rw-r--r--PC/clinic/msvcrtmodule.c.h86
-rw-r--r--PC/clinic/winreg.c.h32
-rw-r--r--Python/clinic/bltinmodule.c.h18
-rw-r--r--Python/clinic/import.c.h28
-rw-r--r--Python/clinic/marshal.c.h39
-rw-r--r--Python/clinic/sysmodule.c.h29
-rw-r--r--Python/getargs.c43
-rwxr-xr-xTools/clinic/clinic.py249
60 files changed, 6194 insertions, 778 deletions
diff --git a/Include/modsupport.h b/Include/modsupport.h
index ed24b2b..f17060c 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -66,7 +66,12 @@ PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
#define _PyArg_NoPositional(funcname, args) \
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
-PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, PyObject *);
+PyAPI_FUNC(void) _PyArg_BadArgument(const char *, int, const char *, PyObject *);
+PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
+ Py_ssize_t, Py_ssize_t);
+#define _PyArg_CheckPositional(funcname, nargs, min, max) \
+ (((min) <= (nargs) && (nargs) <= (max)) \
+ || _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
#endif
diff --git a/Lib/test/clinic.test b/Lib/test/clinic.test
index 03571a8..7ae8f96 100644
--- a/Lib/test/clinic.test
+++ b/Lib/test/clinic.test
@@ -35,10 +35,19 @@ test_object_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *c;
PyUnicode_Object *d;
- if (!_PyArg_ParseStack(args, nargs, "OO&O!O:test_object_converter",
- &a, PyUnicode_FSConverter, &b, &PyUnicode_Type, &c, &d)) {
+ if (!_PyArg_CheckPositional("test_object_converter", nargs, 4, 4)) {
goto exit;
}
+ a = args[0];
+ if (!PyUnicode_FSConverter(args[1], &b)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[2])) {
+ _PyArg_BadArgument("test_object_converter", 3, "str", args[2]);
+ goto exit;
+ }
+ c = args[2];
+ d = (PyUnicode_Object *)args[3];
return_value = test_object_converter_impl(module, a, b, c, d);
exit:
@@ -48,7 +57,7 @@ exit:
static PyObject *
test_object_converter_impl(PyObject *module, PyObject *a, PyObject *b,
PyObject *c, PyUnicode_Object *d)
-/*[clinic end generated code: output=ac25517226de46c8 input=005e6a8a711a869b]*/
+/*[clinic end generated code: output=f2c26174b3d46e94 input=005e6a8a711a869b]*/
/*[clinic input]
test_object_converter_one_arg
@@ -159,10 +168,59 @@ test_object_converter_subclass_of(PyObject *module, PyObject *const *args, Py_ss
PyObject *i;
PyObject *j;
- if (!_PyArg_ParseStack(args, nargs, "O!O!O!O!O!O!O!O!O!O!:test_object_converter_subclass_of",
- &PyLong_Type, &a, &PyTuple_Type, &b, &PyList_Type, &c, &PySet_Type, &d, &PyFrozenSet_Type, &e, &PyDict_Type, &f, &PyUnicode_Type, &g, &PyBytes_Type, &h, &PyByteArray_Type, &i, &MyType, &j)) {
+ if (!_PyArg_CheckPositional("test_object_converter_subclass_of", nargs, 10, 10)) {
+ goto exit;
+ }
+ if (!PyLong_Check(args[0])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 1, "int", args[0]);
+ goto exit;
+ }
+ a = args[0];
+ if (!PyTuple_Check(args[1])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 2, "tuple", args[1]);
+ goto exit;
+ }
+ b = args[1];
+ if (!PyList_Check(args[2])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 3, "list", args[2]);
+ goto exit;
+ }
+ c = args[2];
+ if (!PySet_Check(args[3])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 4, "set", args[3]);
+ goto exit;
+ }
+ d = args[3];
+ if (!PyFrozenSet_Check(args[4])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 5, "frozenset", args[4]);
goto exit;
}
+ e = args[4];
+ if (!PyDict_Check(args[5])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 6, "dict", args[5]);
+ goto exit;
+ }
+ f = args[5];
+ if (!PyUnicode_Check(args[6])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 7, "str", args[6]);
+ goto exit;
+ }
+ g = args[6];
+ if (!PyBytes_Check(args[7])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 8, "bytes", args[7]);
+ goto exit;
+ }
+ h = args[7];
+ if (!PyByteArray_Check(args[8])) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 9, "bytearray", args[8]);
+ goto exit;
+ }
+ i = args[8];
+ if (!PyObject_TypeCheck(args[9], &MyType)) {
+ _PyArg_BadArgument("test_object_converter_subclass_of", 10, (&MyType)->tp_name, args[9]);
+ goto exit;
+ }
+ j = args[9];
return_value = test_object_converter_subclass_of_impl(module, a, b, c, d, e, f, g, h, i, j);
exit:
@@ -174,7 +232,7 @@ test_object_converter_subclass_of_impl(PyObject *module, PyObject *a,
PyObject *b, PyObject *c, PyObject *d,
PyObject *e, PyObject *f, PyObject *g,
PyObject *h, PyObject *i, PyObject *j)
-/*[clinic end generated code: output=b26bcdc31dfc7872 input=31b06b772d5f983e]*/
+/*[clinic end generated code: output=99691bda8eeda6d6 input=31b06b772d5f983e]*/
/*[clinic input]
test_PyBytesObject_converter
@@ -202,7 +260,7 @@ test_PyBytesObject_converter(PyObject *module, PyObject *arg)
PyBytesObject *a;
if (!PyBytes_Check(arg)) {
- _PyArg_BadArgument("test_PyBytesObject_converter", "bytes", arg);
+ _PyArg_BadArgument("test_PyBytesObject_converter", 0, "bytes", arg);
goto exit;
}
a = (PyBytesObject *)arg;
@@ -214,7 +272,7 @@ exit:
static PyObject *
test_PyBytesObject_converter_impl(PyObject *module, PyBytesObject *a)
-/*[clinic end generated code: output=fd69d6df4d26c853 input=12b10c7cb5750400]*/
+/*[clinic end generated code: output=5d9a301c1df24eb5 input=12b10c7cb5750400]*/
/*[clinic input]
test_PyByteArrayObject_converter
@@ -242,7 +300,7 @@ test_PyByteArrayObject_converter(PyObject *module, PyObject *arg)
PyByteArrayObject *a;
if (!PyByteArray_Check(arg)) {
- _PyArg_BadArgument("test_PyByteArrayObject_converter", "bytearray", arg);
+ _PyArg_BadArgument("test_PyByteArrayObject_converter", 0, "bytearray", arg);
goto exit;
}
a = (PyByteArrayObject *)arg;
@@ -254,7 +312,7 @@ exit:
static PyObject *
test_PyByteArrayObject_converter_impl(PyObject *module, PyByteArrayObject *a)
-/*[clinic end generated code: output=d309c909182c4183 input=5a657da535d194ae]*/
+/*[clinic end generated code: output=9455d06f4f09637b input=5a657da535d194ae]*/
/*[clinic input]
test_unicode_converter
@@ -282,7 +340,7 @@ test_unicode_converter(PyObject *module, PyObject *arg)
PyObject *a;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("test_unicode_converter", "str", arg);
+ _PyArg_BadArgument("test_unicode_converter", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -297,7 +355,7 @@ exit:
static PyObject *
test_unicode_converter_impl(PyObject *module, PyObject *a)
-/*[clinic end generated code: output=ca603454e1f8f764 input=aa33612df92aa9c5]*/
+/*[clinic end generated code: output=9275c04fe204f4c5 input=aa33612df92aa9c5]*/
/*[clinic input]
test_bool_converter
@@ -328,10 +386,36 @@ test_bool_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int b = 1;
int c = 1;
- if (!_PyArg_ParseStack(args, nargs, "|ppi:test_bool_converter",
- &a, &b, &c)) {
+ if (!_PyArg_CheckPositional("test_bool_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ a = PyObject_IsTrue(args[0]);
+ if (a < 0) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ b = PyObject_IsTrue(args[1]);
+ if (b < 0) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ c = _PyLong_AsInt(args[2]);
+ if (c == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = test_bool_converter_impl(module, a, b, c);
exit:
@@ -340,7 +424,7 @@ exit:
static PyObject *
test_bool_converter_impl(PyObject *module, int a, int b, int c)
-/*[clinic end generated code: output=f08a22d3390ab6f7 input=939854fa9f248c60]*/
+/*[clinic end generated code: output=25f20963894256a1 input=939854fa9f248c60]*/
/*[clinic input]
test_char_converter
@@ -397,10 +481,192 @@ test_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
char m = '\x00';
char n = '\xff';
- if (!_PyArg_ParseStack(args, nargs, "|cccccccccccccc:test_char_converter",
- &a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n)) {
+ if (!_PyArg_CheckPositional("test_char_converter", nargs, 0, 14)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[0]) && PyBytes_GET_SIZE(args[0]) == 1) {
+ a = PyBytes_AS_STRING(args[0])[0];
+ }
+ else if (PyByteArray_Check(args[0]) && PyByteArray_GET_SIZE(args[0]) == 1) {
+ a = PyByteArray_AS_STRING(args[0])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 1, "a byte string of length 1", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[1]) && PyBytes_GET_SIZE(args[1]) == 1) {
+ b = PyBytes_AS_STRING(args[1])[0];
+ }
+ else if (PyByteArray_Check(args[1]) && PyByteArray_GET_SIZE(args[1]) == 1) {
+ b = PyByteArray_AS_STRING(args[1])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 2, "a byte string of length 1", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[2]) && PyBytes_GET_SIZE(args[2]) == 1) {
+ c = PyBytes_AS_STRING(args[2])[0];
+ }
+ else if (PyByteArray_Check(args[2]) && PyByteArray_GET_SIZE(args[2]) == 1) {
+ c = PyByteArray_AS_STRING(args[2])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 3, "a byte string of length 1", args[2]);
+ goto exit;
+ }
+ if (nargs < 4) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[3]) && PyBytes_GET_SIZE(args[3]) == 1) {
+ d = PyBytes_AS_STRING(args[3])[0];
+ }
+ else if (PyByteArray_Check(args[3]) && PyByteArray_GET_SIZE(args[3]) == 1) {
+ d = PyByteArray_AS_STRING(args[3])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 4, "a byte string of length 1", args[3]);
+ goto exit;
+ }
+ if (nargs < 5) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[4]) && PyBytes_GET_SIZE(args[4]) == 1) {
+ e = PyBytes_AS_STRING(args[4])[0];
+ }
+ else if (PyByteArray_Check(args[4]) && PyByteArray_GET_SIZE(args[4]) == 1) {
+ e = PyByteArray_AS_STRING(args[4])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 5, "a byte string of length 1", args[4]);
+ goto exit;
+ }
+ if (nargs < 6) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[5]) && PyBytes_GET_SIZE(args[5]) == 1) {
+ f = PyBytes_AS_STRING(args[5])[0];
+ }
+ else if (PyByteArray_Check(args[5]) && PyByteArray_GET_SIZE(args[5]) == 1) {
+ f = PyByteArray_AS_STRING(args[5])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 6, "a byte string of length 1", args[5]);
+ goto exit;
+ }
+ if (nargs < 7) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[6]) && PyBytes_GET_SIZE(args[6]) == 1) {
+ g = PyBytes_AS_STRING(args[6])[0];
+ }
+ else if (PyByteArray_Check(args[6]) && PyByteArray_GET_SIZE(args[6]) == 1) {
+ g = PyByteArray_AS_STRING(args[6])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 7, "a byte string of length 1", args[6]);
+ goto exit;
+ }
+ if (nargs < 8) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[7]) && PyBytes_GET_SIZE(args[7]) == 1) {
+ h = PyBytes_AS_STRING(args[7])[0];
+ }
+ else if (PyByteArray_Check(args[7]) && PyByteArray_GET_SIZE(args[7]) == 1) {
+ h = PyByteArray_AS_STRING(args[7])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 8, "a byte string of length 1", args[7]);
+ goto exit;
+ }
+ if (nargs < 9) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[8]) && PyBytes_GET_SIZE(args[8]) == 1) {
+ i = PyBytes_AS_STRING(args[8])[0];
+ }
+ else if (PyByteArray_Check(args[8]) && PyByteArray_GET_SIZE(args[8]) == 1) {
+ i = PyByteArray_AS_STRING(args[8])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 9, "a byte string of length 1", args[8]);
+ goto exit;
+ }
+ if (nargs < 10) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[9]) && PyBytes_GET_SIZE(args[9]) == 1) {
+ j = PyBytes_AS_STRING(args[9])[0];
+ }
+ else if (PyByteArray_Check(args[9]) && PyByteArray_GET_SIZE(args[9]) == 1) {
+ j = PyByteArray_AS_STRING(args[9])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 10, "a byte string of length 1", args[9]);
+ goto exit;
+ }
+ if (nargs < 11) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[10]) && PyBytes_GET_SIZE(args[10]) == 1) {
+ k = PyBytes_AS_STRING(args[10])[0];
+ }
+ else if (PyByteArray_Check(args[10]) && PyByteArray_GET_SIZE(args[10]) == 1) {
+ k = PyByteArray_AS_STRING(args[10])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 11, "a byte string of length 1", args[10]);
+ goto exit;
+ }
+ if (nargs < 12) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[11]) && PyBytes_GET_SIZE(args[11]) == 1) {
+ l = PyBytes_AS_STRING(args[11])[0];
+ }
+ else if (PyByteArray_Check(args[11]) && PyByteArray_GET_SIZE(args[11]) == 1) {
+ l = PyByteArray_AS_STRING(args[11])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 12, "a byte string of length 1", args[11]);
+ goto exit;
+ }
+ if (nargs < 13) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[12]) && PyBytes_GET_SIZE(args[12]) == 1) {
+ m = PyBytes_AS_STRING(args[12])[0];
+ }
+ else if (PyByteArray_Check(args[12]) && PyByteArray_GET_SIZE(args[12]) == 1) {
+ m = PyByteArray_AS_STRING(args[12])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 13, "a byte string of length 1", args[12]);
+ goto exit;
+ }
+ if (nargs < 14) {
+ goto skip_optional;
+ }
+ if (PyBytes_Check(args[13]) && PyBytes_GET_SIZE(args[13]) == 1) {
+ n = PyBytes_AS_STRING(args[13])[0];
+ }
+ else if (PyByteArray_Check(args[13]) && PyByteArray_GET_SIZE(args[13]) == 1) {
+ n = PyByteArray_AS_STRING(args[13])[0];
+ }
+ else {
+ _PyArg_BadArgument("test_char_converter", 14, "a byte string of length 1", args[13]);
goto exit;
}
+skip_optional:
return_value = test_char_converter_impl(module, a, b, c, d, e, f, g, h, i, j, k, l, m, n);
exit:
@@ -411,7 +677,7 @@ static PyObject *
test_char_converter_impl(PyObject *module, char a, char b, char c, char d,
char e, char f, char g, char h, char i, char j,
char k, char l, char m, char n)
-/*[clinic end generated code: output=14c61e8ee78f3d47 input=e42330417a44feac]*/
+/*[clinic end generated code: output=e041d687555e0a5d input=e42330417a44feac]*/
/*[clinic input]
test_unsigned_char_converter
@@ -443,10 +709,81 @@ test_unsigned_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t
unsigned char b = 34;
unsigned char c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|bbB:test_unsigned_char_converter",
- &a, &b, &c)) {
+ if (!_PyArg_CheckPositional("test_unsigned_char_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsLong(args[0]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned byte integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > UCHAR_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned byte integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ a = (unsigned char) ival;
+ }
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(args[1]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned byte integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > UCHAR_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned byte integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ b = (unsigned char) ival;
+ }
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsUnsignedLongMask(args[2]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else {
+ c = (unsigned char) ival;
+ }
+ }
+skip_optional:
return_value = test_unsigned_char_converter_impl(module, a, b, c);
exit:
@@ -456,7 +793,7 @@ exit:
static PyObject *
test_unsigned_char_converter_impl(PyObject *module, unsigned char a,
unsigned char b, unsigned char c)
-/*[clinic end generated code: output=a4fd7ad26077dcfc input=021414060993e289]*/
+/*[clinic end generated code: output=ebf905c5c9414762 input=021414060993e289]*/
/*[clinic input]
test_short_converter
@@ -483,10 +820,37 @@ test_short_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
short a = 12;
- if (!_PyArg_ParseStack(args, nargs, "|h:test_short_converter",
- &a)) {
+ if (!_PyArg_CheckPositional("test_short_converter", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(args[0]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ a = (short) ival;
+ }
+ }
+skip_optional:
return_value = test_short_converter_impl(module, a);
exit:
@@ -495,7 +859,7 @@ exit:
static PyObject *
test_short_converter_impl(PyObject *module, short a)
-/*[clinic end generated code: output=08259a92c12890b1 input=6a8a7a509a498ff4]*/
+/*[clinic end generated code: output=86fe1a1496a7ff20 input=6a8a7a509a498ff4]*/
/*[clinic input]
test_unsigned_short_converter
@@ -527,10 +891,34 @@ test_unsigned_short_converter(PyObject *module, PyObject *const *args, Py_ssize_
unsigned short b = 34;
unsigned short c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|O&O&H:test_unsigned_short_converter",
- _PyLong_UnsignedShort_Converter, &a, _PyLong_UnsignedShort_Converter, &b, &c)) {
+ if (!_PyArg_CheckPositional("test_unsigned_short_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedShort_Converter(args[0], &a)) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedShort_Converter(args[1], &b)) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ c = (unsigned short)PyLong_AsUnsignedLongMask(args[2]);
+ if (c == (unsigned short)-1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = test_unsigned_short_converter_impl(module, a, b, c);
exit:
@@ -540,7 +928,7 @@ exit:
static PyObject *
test_unsigned_short_converter_impl(PyObject *module, unsigned short a,
unsigned short b, unsigned short c)
-/*[clinic end generated code: output=d714bceb98c1fe84 input=cdfd8eff3d9176b4]*/
+/*[clinic end generated code: output=3779fe104319e3ae input=cdfd8eff3d9176b4]*/
/*[clinic input]
test_int_converter
@@ -573,10 +961,61 @@ test_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int c = 45;
myenum d = 67;
- if (!_PyArg_ParseStack(args, nargs, "|iiCi:test_int_converter",
- &a, &b, &c, &d)) {
+ if (!_PyArg_CheckPositional("test_int_converter", nargs, 0, 4)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ a = _PyLong_AsInt(args[0]);
+ if (a == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ b = _PyLong_AsInt(args[1]);
+ if (b == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (!PyUnicode_Check(args[2])) {
+ _PyArg_BadArgument("test_int_converter", 3, "a unicode character", args[2]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[2])) {
+ goto exit;
+ }
+ if (PyUnicode_GET_LENGTH(args[2]) != 1) {
+ _PyArg_BadArgument("test_int_converter", 3, "a unicode character", args[2]);
+ goto exit;
+ }
+ c = PyUnicode_READ_CHAR(args[2], 0);
+ if (nargs < 4) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[3])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ d = _PyLong_AsInt(args[3]);
+ if (d == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = test_int_converter_impl(module, a, b, c, d);
exit:
@@ -585,7 +1024,7 @@ exit:
static PyObject *
test_int_converter_impl(PyObject *module, int a, int b, int c, myenum d)
-/*[clinic end generated code: output=1995799d5264e4a5 input=d20541fc1ca0553e]*/
+/*[clinic end generated code: output=de74e24e85a669a5 input=d20541fc1ca0553e]*/
/*[clinic input]
test_unsigned_int_converter
@@ -617,10 +1056,34 @@ test_unsigned_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t
unsigned int b = 34;
unsigned int c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|O&O&I:test_unsigned_int_converter",
- _PyLong_UnsignedInt_Converter, &a, _PyLong_UnsignedInt_Converter, &b, &c)) {
+ if (!_PyArg_CheckPositional("test_unsigned_int_converter", nargs, 0, 3)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedInt_Converter(args[0], &a)) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedInt_Converter(args[1], &b)) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ c = (unsigned int)PyLong_AsUnsignedLongMask(args[2]);
+ if (c == (unsigned int)-1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = test_unsigned_int_converter_impl(module, a, b, c);
exit:
@@ -630,7 +1093,7 @@ exit:
static PyObject *
test_unsigned_int_converter_impl(PyObject *module, unsigned int a,
unsigned int b, unsigned int c)
-/*[clinic end generated code: output=3cdb7a3ef2b369a3 input=5533534828b62fc0]*/
+/*[clinic end generated code: output=189176ce67c7d2e7 input=5533534828b62fc0]*/
/*[clinic input]
test_long_converter
@@ -657,10 +1120,22 @@ test_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
long a = 12;
- if (!_PyArg_ParseStack(args, nargs, "|l:test_long_converter",
- &a)) {
+ if (!_PyArg_CheckPositional("test_long_converter", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ a = PyLong_AsLong(args[0]);
+ if (a == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = test_long_converter_impl(module, a);
exit:
@@ -669,7 +1144,7 @@ exit:
static PyObject *
test_long_converter_impl(PyObject *module, long a)
-/*[clinic end generated code: output=65a8092a1dc10de6 input=d2179e3c9cdcde89]*/
+/*[clinic end generated code: output=44cd8823f59d116b input=d2179e3c9cdcde89]*/
/*[clinic input]
test_unsigned_long_converter
@@ -701,10 +1176,30 @@ test_unsigned_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t
unsigned long b = 34;
unsigned long c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|O&O&k:test_unsigned_long_converter",
- _PyLong_UnsignedLong_Converter, &a, _PyLong_UnsignedLong_Converter, &b, &c)) {
+ if (!_PyArg_CheckPositional("test_unsigned_long_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedLong_Converter(args[0], &a)) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedLong_Converter(args[1], &b)) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (!PyLong_Check(args[2])) {
+ _PyArg_BadArgument("test_unsigned_long_converter", 3, "int", args[2]);
goto exit;
}
+ c = PyLong_AsUnsignedLongMask(args[2]);
+skip_optional:
return_value = test_unsigned_long_converter_impl(module, a, b, c);
exit:
@@ -714,7 +1209,7 @@ exit:
static PyObject *
test_unsigned_long_converter_impl(PyObject *module, unsigned long a,
unsigned long b, unsigned long c)
-/*[clinic end generated code: output=81fd66d8981abeb2 input=f450d94cae1ef73b]*/
+/*[clinic end generated code: output=1c05c871c0309e08 input=f450d94cae1ef73b]*/
/*[clinic input]
test_long_long_converter
@@ -741,10 +1236,22 @@ test_long_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t nar
PyObject *return_value = NULL;
long long a = 12;
- if (!_PyArg_ParseStack(args, nargs, "|L:test_long_long_converter",
- &a)) {
+ if (!_PyArg_CheckPositional("test_long_long_converter", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ a = PyLong_AsLongLong(args[0]);
+ if (a == (PY_LONG_LONG)-1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = test_long_long_converter_impl(module, a);
exit:
@@ -753,7 +1260,7 @@ exit:
static PyObject *
test_long_long_converter_impl(PyObject *module, long long a)
-/*[clinic end generated code: output=9412f5800661b0c0 input=d5fc81577ff4dd02]*/
+/*[clinic end generated code: output=3e8083f3aee4f18a input=d5fc81577ff4dd02]*/
/*[clinic input]
test_unsigned_long_long_converter
@@ -787,10 +1294,30 @@ test_unsigned_long_long_converter(PyObject *module, PyObject *const *args, Py_ss
unsigned long long b = 34;
unsigned long long c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|O&O&K:test_unsigned_long_long_converter",
- _PyLong_UnsignedLongLong_Converter, &a, _PyLong_UnsignedLongLong_Converter, &b, &c)) {
+ if (!_PyArg_CheckPositional("test_unsigned_long_long_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedLongLong_Converter(args[0], &a)) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!_PyLong_UnsignedLongLong_Converter(args[1], &b)) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (!PyLong_Check(args[2])) {
+ _PyArg_BadArgument("test_unsigned_long_long_converter", 3, "int", args[2]);
goto exit;
}
+ c = PyLong_AsUnsignedLongLongMask(args[2]);
+skip_optional:
return_value = test_unsigned_long_long_converter_impl(module, a, b, c);
exit:
@@ -802,7 +1329,7 @@ test_unsigned_long_long_converter_impl(PyObject *module,
unsigned long long a,
unsigned long long b,
unsigned long long c)
-/*[clinic end generated code: output=f5a57e0ccc048a32 input=a15115dc41866ff4]*/
+/*[clinic end generated code: output=0a9b17fb824e28eb input=a15115dc41866ff4]*/
/*[clinic input]
test_Py_ssize_t_converter
@@ -834,10 +1361,56 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
Py_ssize_t b = 34;
Py_ssize_t c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|nnO&:test_Py_ssize_t_converter",
- &a, &b, _Py_convert_optional_to_ssize_t, &c)) {
+ if (!_PyArg_CheckPositional("test_Py_ssize_t_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ a = ival;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ b = ival;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[2], &c)) {
+ goto exit;
+ }
+skip_optional:
return_value = test_Py_ssize_t_converter_impl(module, a, b, c);
exit:
@@ -847,7 +1420,7 @@ exit:
static PyObject *
test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b,
Py_ssize_t c)
-/*[clinic end generated code: output=50bc360c57b40e3f input=3855f184bb3f299d]*/
+/*[clinic end generated code: output=a46d2aaf40c10398 input=3855f184bb3f299d]*/
/*[clinic input]
test_slice_index_converter
@@ -879,10 +1452,28 @@ test_slice_index_converter(PyObject *module, PyObject *const *args, Py_ssize_t n
Py_ssize_t b = 34;
Py_ssize_t c = 56;
- if (!_PyArg_ParseStack(args, nargs, "|O&O&O&:test_slice_index_converter",
- _PyEval_SliceIndex, &a, _PyEval_SliceIndexNotNone, &b, _PyEval_SliceIndex, &c)) {
+ if (!_PyArg_CheckPositional("test_slice_index_converter", nargs, 0, 3)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_PyEval_SliceIndex(args[0], &a)) {
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!_PyEval_SliceIndexNotNone(args[1], &b)) {
goto exit;
}
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (!_PyEval_SliceIndex(args[2], &c)) {
+ goto exit;
+ }
+skip_optional:
return_value = test_slice_index_converter_impl(module, a, b, c);
exit:
@@ -892,7 +1483,7 @@ exit:
static PyObject *
test_slice_index_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b,
Py_ssize_t c)
-/*[clinic end generated code: output=33b9152bf3c5963a input=edeadb0ee126f531]*/
+/*[clinic end generated code: output=2148703cd3c6e941 input=edeadb0ee126f531]*/
/*[clinic input]
test_size_t_converter
@@ -919,10 +1510,16 @@ test_size_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
size_t a = 12;
- if (!_PyArg_ParseStack(args, nargs, "|O&:test_size_t_converter",
- _PyLong_Size_t_Converter, &a)) {
+ if (!_PyArg_CheckPositional("test_size_t_converter", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_PyLong_Size_t_Converter(args[0], &a)) {
+ goto exit;
+ }
+skip_optional:
return_value = test_size_t_converter_impl(module, a);
exit:
@@ -931,7 +1528,7 @@ exit:
static PyObject *
test_size_t_converter_impl(PyObject *module, size_t a)
-/*[clinic end generated code: output=02fe6bf4c5a139d5 input=52e93a0fed0f1fb3]*/
+/*[clinic end generated code: output=8a91a9ca8a92dabb input=52e93a0fed0f1fb3]*/
/*[clinic input]
test_float_converter
@@ -958,10 +1555,17 @@ test_float_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
float a = 12.5;
- if (!_PyArg_ParseStack(args, nargs, "|f:test_float_converter",
- &a)) {
+ if (!_PyArg_CheckPositional("test_float_converter", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ a = (float) PyFloat_AsDouble(args[0]);
+ if (PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = test_float_converter_impl(module, a);
exit:
@@ -970,7 +1574,7 @@ exit:
static PyObject *
test_float_converter_impl(PyObject *module, float a)
-/*[clinic end generated code: output=a0689b5ee76673ad input=259c0d98eca35034]*/
+/*[clinic end generated code: output=8293566b2ec1fc52 input=259c0d98eca35034]*/
/*[clinic input]
test_double_converter
@@ -997,10 +1601,17 @@ test_double_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
double a = 12.5;
- if (!_PyArg_ParseStack(args, nargs, "|d:test_double_converter",
- &a)) {
+ if (!_PyArg_CheckPositional("test_double_converter", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ a = PyFloat_AsDouble(args[0]);
+ if (PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = test_double_converter_impl(module, a);
exit:
@@ -1009,7 +1620,7 @@ exit:
static PyObject *
test_double_converter_impl(PyObject *module, double a)
-/*[clinic end generated code: output=b78d23bd37b40681 input=c6a9945706a41c27]*/
+/*[clinic end generated code: output=487081a9b8da67ab input=c6a9945706a41c27]*/
/*[clinic input]
test_Py_complex_converter
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index 6569e02..6345b9e 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -21,11 +21,11 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
@@ -58,11 +58,11 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto1", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto1", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto1", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
@@ -114,10 +114,30 @@ _io__Buffered_peek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = 0;
- if (!_PyArg_ParseStack(args, nargs, "|n:peek",
- &size)) {
+ if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ size = ival;
+ }
+skip_optional:
return_value = _io__Buffered_peek_impl(self, size);
exit:
@@ -141,10 +161,16 @@ _io__Buffered_read(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &n)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
goto exit;
}
+skip_optional:
return_value = _io__Buffered_read_impl(self, n);
exit:
@@ -168,10 +194,30 @@ _io__Buffered_read1(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
- if (!_PyArg_ParseStack(args, nargs, "|n:read1",
- &n)) {
+ if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ n = ival;
+ }
+skip_optional:
return_value = _io__Buffered_read1_impl(self, n);
exit:
@@ -197,11 +243,11 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto_impl(self, &buffer);
@@ -234,11 +280,11 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto1", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto1", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto1", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto1_impl(self, &buffer);
@@ -269,10 +315,16 @@ _io__Buffered_readline(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io__Buffered_readline_impl(self, size);
exit:
@@ -297,10 +349,23 @@ _io__Buffered_seek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *targetobj;
int whence = 0;
- if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
- &targetobj, &whence)) {
+ if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
+ goto exit;
+ }
+ targetobj = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ whence = _PyLong_AsInt(args[1]);
+ if (whence == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _io__Buffered_seek_impl(self, targetobj, whence);
exit:
@@ -418,7 +483,7 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("write", "contiguous buffer", arg);
+ _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_BufferedWriter_write_impl(self, &buffer);
@@ -462,10 +527,32 @@ _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit;
}
- if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
- &reader, &writer, &buffer_size)) {
+ if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) {
goto exit;
}
+ reader = PyTuple_GET_ITEM(args, 0);
+ writer = PyTuple_GET_ITEM(args, 1);
+ if (PyTuple_GET_SIZE(args) < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(PyTuple_GET_ITEM(args, 2))) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 2));
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ buffer_size = ival;
+ }
+skip_optional:
return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
exit:
@@ -504,4 +591,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a85f61f495feff5c input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index 07c8866..5588416 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -169,10 +169,16 @@ _io_BytesIO_read(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_BytesIO_read_impl(self, size);
exit:
@@ -200,10 +206,16 @@ _io_BytesIO_read1(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read1",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
+skip_optional:
return_value = _io_BytesIO_read1_impl(self, size);
exit:
@@ -232,10 +244,16 @@ _io_BytesIO_readline(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_BytesIO_readline_impl(self, size);
exit:
@@ -298,11 +316,11 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_BytesIO_readinto_impl(self, &buffer);
@@ -337,10 +355,16 @@ _io_BytesIO_truncate(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = self->pos;
- if (!_PyArg_ParseStack(args, nargs, "|O&:truncate",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
+skip_optional:
return_value = _io_BytesIO_truncate_impl(self, size);
exit:
@@ -372,10 +396,39 @@ _io_BytesIO_seek(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t pos;
int whence = 0;
- if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
- &pos, &whence)) {
+ if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ whence = _PyLong_AsInt(args[1]);
+ if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit:
@@ -450,4 +503,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5c68eb481fa960bf input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index bf40f7f..280549e 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -158,11 +158,11 @@ _io_FileIO_readinto(fileio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_FileIO_readinto_impl(self, &buffer);
@@ -219,10 +219,16 @@ _io_FileIO_read(fileio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_FileIO_read_impl(self, size);
exit:
@@ -255,7 +261,7 @@ _io_FileIO_write(fileio *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
- _PyArg_BadArgument("write", "contiguous buffer", arg);
+ _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_FileIO_write_impl(self, &b);
@@ -296,10 +302,23 @@ _io_FileIO_seek(fileio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *pos;
int whence = 0;
- if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
- &pos, &whence)) {
+ if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
+ goto exit;
+ }
+ pos = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ whence = _PyLong_AsInt(args[1]);
+ if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _io_FileIO_seek_impl(self, pos, whence);
exit:
@@ -383,4 +402,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
-/*[clinic end generated code: output=8be0ea9a5ac7aa43 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4cf4e5f0cd656b11 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h
index 68eaadd..a5c8eea 100644
--- a/Modules/_io/clinic/iobase.c.h
+++ b/Modules/_io/clinic/iobase.c.h
@@ -185,10 +185,16 @@ _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t limit = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
- _Py_convert_optional_to_ssize_t, &limit)) {
+ if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io__IOBase_readline_impl(self, limit);
exit:
@@ -217,10 +223,16 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t hint = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:readlines",
- _Py_convert_optional_to_ssize_t, &hint)) {
+ if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) {
goto exit;
}
+skip_optional:
return_value = _io__IOBase_readlines_impl(self, hint);
exit:
@@ -252,10 +264,30 @@ _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
- if (!_PyArg_ParseStack(args, nargs, "|n:read",
- &n)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ n = ival;
+ }
+skip_optional:
return_value = _io__RawIOBase_read_impl(self, n);
exit:
@@ -279,4 +311,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__RawIOBase_readall_impl(self);
}
-/*[clinic end generated code: output=cde4b0e96a4e69e3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=60e43a7cbd9f314e input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h
index 3181688..1757d83 100644
--- a/Modules/_io/clinic/stringio.c.h
+++ b/Modules/_io/clinic/stringio.c.h
@@ -59,10 +59,16 @@ _io_StringIO_read(stringio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_StringIO_read_impl(self, size);
exit:
@@ -89,10 +95,16 @@ _io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_StringIO_readline_impl(self, size);
exit:
@@ -121,10 +133,16 @@ _io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = self->pos;
- if (!_PyArg_ParseStack(args, nargs, "|O&:truncate",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
+skip_optional:
return_value = _io_StringIO_truncate_impl(self, size);
exit:
@@ -156,10 +174,39 @@ _io_StringIO_seek(stringio *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t pos;
int whence = 0;
- if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
- &pos, &whence)) {
+ if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ whence = _PyLong_AsInt(args[1]);
+ if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _io_StringIO_seek_impl(self, pos, whence);
exit:
@@ -286,4 +333,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_seekable_impl(self);
}
-/*[clinic end generated code: output=00c3c7a1c6ea6773 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=db5e51dcc4dae8d5 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index f056416e..0ff0324 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -251,7 +251,7 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg)
PyObject *text;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("write", "str", arg);
+ _PyArg_BadArgument("write", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -281,10 +281,16 @@ _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &n)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_TextIOWrapper_read_impl(self, n);
exit:
@@ -308,10 +314,30 @@ _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|n:readline",
- &size)) {
+ if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ size = ival;
+ }
+skip_optional:
return_value = _io_TextIOWrapper_readline_impl(self, size);
exit:
@@ -336,10 +362,23 @@ _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *cookieObj;
int whence = 0;
- if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
- &cookieObj, &whence)) {
+ if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
+ goto exit;
+ }
+ cookieObj = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ whence = _PyLong_AsInt(args[1]);
+ if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit:
@@ -509,4 +548,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8bdd1035bf878d6f input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h
index 65cac66..e7cd854 100644
--- a/Modules/_io/clinic/winconsoleio.c.h
+++ b/Modules/_io/clinic/winconsoleio.c.h
@@ -158,11 +158,11 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
- _PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
+ _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("readinto", "contiguous buffer", arg);
+ _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
@@ -226,10 +226,16 @@ _io__WindowsConsoleIO_read(winconsoleio *self, PyObject *const *args, Py_ssize_t
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &size)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io__WindowsConsoleIO_read_impl(self, size);
exit:
@@ -265,7 +271,7 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
- _PyArg_BadArgument("write", "contiguous buffer", arg);
+ _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__WindowsConsoleIO_write_impl(self, &b);
@@ -338,4 +344,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
-/*[clinic end generated code: output=4337e8de65915a1e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ab0f0ee8062eecb3 input=a9049054013a1b77]*/
diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h
index 1fef185..871bf33 100644
--- a/Modules/cjkcodecs/clinic/multibytecodec.c.h
+++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h
@@ -151,7 +151,7 @@ _multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoder
PyLongObject *statelong;
if (!PyLong_Check(arg)) {
- _PyArg_BadArgument("setstate", "int", arg);
+ _PyArg_BadArgument("setstate", 0, "int", arg);
goto exit;
}
statelong = (PyLongObject *)arg;
@@ -251,7 +251,7 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoder
PyObject *state;
if (!PyTuple_Check(arg)) {
- _PyArg_BadArgument("setstate", "tuple", arg);
+ _PyArg_BadArgument("setstate", 0, "tuple", arg);
goto exit;
}
state = arg;
@@ -422,4 +422,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
-/*[clinic end generated code: output=a94364d0965adf1d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2ed7030b28a79029 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_bz2module.c.h b/Modules/clinic/_bz2module.c.h
index dce746d..fb64333 100644
--- a/Modules/clinic/_bz2module.c.h
+++ b/Modules/clinic/_bz2module.c.h
@@ -29,7 +29,7 @@ _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
- _PyArg_BadArgument("compress", "contiguous buffer", arg);
+ _PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _bz2_BZ2Compressor_compress_impl(self, &data);
@@ -89,10 +89,22 @@ _bz2_BZ2Compressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("BZ2Compressor", kwargs)) {
goto exit;
}
- if (!PyArg_ParseTuple(args, "|i:BZ2Compressor",
- &compresslevel)) {
+ if (!_PyArg_CheckPositional("BZ2Compressor", PyTuple_GET_SIZE(args), 0, 1)) {
goto exit;
}
+ if (PyTuple_GET_SIZE(args) < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ compresslevel = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0));
+ if (compresslevel == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _bz2_BZ2Compressor___init___impl((BZ2Compressor *)self, compresslevel);
exit:
@@ -178,4 +190,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=8549cccdb82f57d9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=892c6133e97ff840 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h
index 360a134..a8223ad 100644
--- a/Modules/clinic/_codecsmodule.c.h
+++ b/Modules/clinic/_codecsmodule.c.h
@@ -34,7 +34,7 @@ _codecs_lookup(PyObject *module, PyObject *arg)
const char *encoding;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("lookup", "str", arg);
+ _PyArg_BadArgument("lookup", 0, "str", arg);
goto exit;
}
Py_ssize_t encoding_length;
@@ -149,7 +149,7 @@ _codecs__forget_codec(PyObject *module, PyObject *arg)
const char *encoding;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("_forget_codec", "str", arg);
+ _PyArg_BadArgument("_forget_codec", 0, "str", arg);
goto exit;
}
Py_ssize_t encoding_length;
@@ -186,10 +186,48 @@ _codecs_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL};
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "s*|z:escape_decode",
- &data, &errors)) {
+ if (!_PyArg_CheckPositional("escape_decode", nargs, 1, 2)) {
goto exit;
}
+ if (PyUnicode_Check(args[0])) {
+ Py_ssize_t len;
+ const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
+ if (ptr == NULL) {
+ goto exit;
+ }
+ PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+ }
+ else { /* any bytes-like object */
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("escape_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("escape_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_escape_decode_impl(module, &data, errors);
exit:
@@ -220,10 +258,36 @@ _codecs_escape_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *data;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "O!|z:escape_encode",
- &PyBytes_Type, &data, &errors)) {
+ if (!_PyArg_CheckPositional("escape_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyBytes_Check(args[0])) {
+ _PyArg_BadArgument("escape_encode", 1, "bytes", args[0]);
+ goto exit;
+ }
+ data = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("escape_encode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_escape_encode_impl(module, data, errors);
exit:
@@ -249,10 +313,32 @@ _codecs_unicode_internal_decode(PyObject *module, PyObject *const *args, Py_ssiz
PyObject *obj;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "O|z:unicode_internal_decode",
- &obj, &errors)) {
+ if (!_PyArg_CheckPositional("unicode_internal_decode", nargs, 1, 2)) {
+ goto exit;
+ }
+ obj = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("unicode_internal_decode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_unicode_internal_decode_impl(module, obj, errors);
exit:
@@ -279,10 +365,50 @@ _codecs_utf_7_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_7_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_7_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_7_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_7_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_7_decode_impl(module, &data, errors, final);
exit:
@@ -314,10 +440,50 @@ _codecs_utf_8_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_8_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_8_decode", nargs, 1, 3)) {
goto exit;
}
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_8_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_8_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_8_decode_impl(module, &data, errors, final);
exit:
@@ -349,10 +515,50 @@ _codecs_utf_16_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_16_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_16_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_16_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_16_decode_impl(module, &data, errors, final);
exit:
@@ -384,10 +590,50 @@ _codecs_utf_16_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_16_le_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_16_le_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_16_le_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_le_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _codecs_utf_16_le_decode_impl(module, &data, errors, final);
exit:
@@ -419,10 +665,50 @@ _codecs_utf_16_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_16_be_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_16_be_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_16_be_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_be_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_16_be_decode_impl(module, &data, errors, final);
exit:
@@ -456,10 +742,62 @@ _codecs_utf_16_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
int byteorder = 0;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zii:utf_16_ex_decode",
- &data, &errors, &byteorder, &final)) {
+ if (!_PyArg_CheckPositional("utf_16_ex_decode", nargs, 1, 4)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_16_ex_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_ex_decode", 2, "str or None", args[1]);
goto exit;
}
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ byteorder = _PyLong_AsInt(args[2]);
+ if (byteorder == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (nargs < 4) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[3])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[3]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_16_ex_decode_impl(module, &data, errors, byteorder, final);
exit:
@@ -491,10 +829,50 @@ _codecs_utf_32_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_32_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_32_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_32_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_32_decode_impl(module, &data, errors, final);
exit:
@@ -526,10 +904,50 @@ _codecs_utf_32_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_32_le_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_32_le_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_32_le_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_le_decode", 2, "str or None", args[1]);
goto exit;
}
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_32_le_decode_impl(module, &data, errors, final);
exit:
@@ -561,10 +979,50 @@ _codecs_utf_32_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:utf_32_be_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("utf_32_be_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_32_be_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_be_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_32_be_decode_impl(module, &data, errors, final);
exit:
@@ -598,10 +1056,62 @@ _codecs_utf_32_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
int byteorder = 0;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zii:utf_32_ex_decode",
- &data, &errors, &byteorder, &final)) {
+ if (!_PyArg_CheckPositional("utf_32_ex_decode", nargs, 1, 4)) {
goto exit;
}
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("utf_32_ex_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_ex_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ byteorder = _PyLong_AsInt(args[2]);
+ if (byteorder == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (nargs < 4) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[3])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[3]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_32_ex_decode_impl(module, &data, errors, byteorder, final);
exit:
@@ -632,10 +1142,48 @@ _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_
Py_buffer data = {NULL, NULL};
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "s*|z:unicode_escape_decode",
- &data, &errors)) {
+ if (!_PyArg_CheckPositional("unicode_escape_decode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyUnicode_Check(args[0])) {
+ Py_ssize_t len;
+ const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
+ if (ptr == NULL) {
+ goto exit;
+ }
+ PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+ }
+ else { /* any bytes-like object */
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("unicode_escape_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("unicode_escape_decode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_unicode_escape_decode_impl(module, &data, errors);
exit:
@@ -666,10 +1214,48 @@ _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ss
Py_buffer data = {NULL, NULL};
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "s*|z:raw_unicode_escape_decode",
- &data, &errors)) {
+ if (!_PyArg_CheckPositional("raw_unicode_escape_decode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyUnicode_Check(args[0])) {
+ Py_ssize_t len;
+ const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
+ if (ptr == NULL) {
+ goto exit;
+ }
+ PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+ }
+ else { /* any bytes-like object */
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("raw_unicode_escape_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("raw_unicode_escape_decode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors);
exit:
@@ -700,10 +1286,38 @@ _codecs_latin_1_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs
Py_buffer data = {NULL, NULL};
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "y*|z:latin_1_decode",
- &data, &errors)) {
+ if (!_PyArg_CheckPositional("latin_1_decode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("latin_1_decode", 1, "contiguous buffer", args[0]);
goto exit;
}
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("latin_1_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_latin_1_decode_impl(module, &data, errors);
exit:
@@ -734,10 +1348,38 @@ _codecs_ascii_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL};
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "y*|z:ascii_decode",
- &data, &errors)) {
+ if (!_PyArg_CheckPositional("ascii_decode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("ascii_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("ascii_decode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_ascii_decode_impl(module, &data, errors);
exit:
@@ -769,10 +1411,42 @@ _codecs_charmap_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs
const char *errors = NULL;
PyObject *mapping = NULL;
- if (!_PyArg_ParseStack(args, nargs, "y*|zO:charmap_decode",
- &data, &errors, &mapping)) {
+ if (!_PyArg_CheckPositional("charmap_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("charmap_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("charmap_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ mapping = args[2];
+skip_optional:
return_value = _codecs_charmap_decode_impl(module, &data, errors, mapping);
exit:
@@ -806,10 +1480,50 @@ _codecs_mbcs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:mbcs_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("mbcs_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("mbcs_decode", 1, "contiguous buffer", args[0]);
goto exit;
}
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("mbcs_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_mbcs_decode_impl(module, &data, errors, final);
exit:
@@ -845,10 +1559,50 @@ _codecs_oem_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "y*|zi:oem_decode",
- &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("oem_decode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("oem_decode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("oem_decode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[2]);
+ if (final == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _codecs_oem_decode_impl(module, &data, errors, final);
exit:
@@ -885,10 +1639,59 @@ _codecs_code_page_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
const char *errors = NULL;
int final = 0;
- if (!_PyArg_ParseStack(args, nargs, "iy*|zi:code_page_decode",
- &codepage, &data, &errors, &final)) {
+ if (!_PyArg_CheckPositional("code_page_decode", nargs, 2, 4)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ codepage = _PyLong_AsInt(args[0]);
+ if (codepage == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("code_page_decode", 2, "contiguous buffer", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (args[2] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[2])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("code_page_decode", 3, "str or None", args[2]);
+ goto exit;
+ }
+ if (nargs < 4) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[3])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[3]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_code_page_decode_impl(module, codepage, &data, errors, final);
exit:
@@ -921,10 +1724,48 @@ _codecs_readbuffer_encode(PyObject *module, PyObject *const *args, Py_ssize_t na
Py_buffer data = {NULL, NULL};
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "s*|z:readbuffer_encode",
- &data, &errors)) {
+ if (!_PyArg_CheckPositional("readbuffer_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (PyUnicode_Check(args[0])) {
+ Py_ssize_t len;
+ const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
+ if (ptr == NULL) {
+ goto exit;
+ }
+ PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+ }
+ else { /* any bytes-like object */
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("readbuffer_encode", 1, "contiguous buffer", args[0]);
+ goto exit;
+ }
+ }
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("readbuffer_encode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_readbuffer_encode_impl(module, &data, errors);
exit:
@@ -955,10 +1796,32 @@ _codecs_unicode_internal_encode(PyObject *module, PyObject *const *args, Py_ssiz
PyObject *obj;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "O|z:unicode_internal_encode",
- &obj, &errors)) {
+ if (!_PyArg_CheckPositional("unicode_internal_encode", nargs, 1, 2)) {
goto exit;
}
+ obj = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("unicode_internal_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_unicode_internal_encode_impl(module, obj, errors);
exit:
@@ -984,10 +1847,39 @@ _codecs_utf_7_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:utf_7_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("utf_7_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_7_encode", 1, "str", args[0]);
goto exit;
}
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_7_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_7_encode_impl(module, str, errors);
exit:
@@ -1013,10 +1905,39 @@ _codecs_utf_8_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:utf_8_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("utf_8_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_8_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_8_encode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_utf_8_encode_impl(module, str, errors);
exit:
@@ -1043,10 +1964,51 @@ _codecs_utf_16_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int byteorder = 0;
- if (!_PyArg_ParseStack(args, nargs, "U|zi:utf_16_encode",
- &str, &errors, &byteorder)) {
+ if (!_PyArg_CheckPositional("utf_16_encode", nargs, 1, 3)) {
goto exit;
}
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_16_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ byteorder = _PyLong_AsInt(args[2]);
+ if (byteorder == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_16_encode_impl(module, str, errors, byteorder);
exit:
@@ -1072,10 +2034,39 @@ _codecs_utf_16_le_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:utf_16_le_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("utf_16_le_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_16_le_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_le_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_16_le_encode_impl(module, str, errors);
exit:
@@ -1101,10 +2092,39 @@ _codecs_utf_16_be_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:utf_16_be_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("utf_16_be_encode", nargs, 1, 2)) {
goto exit;
}
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_16_be_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_16_be_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_16_be_encode_impl(module, str, errors);
exit:
@@ -1131,10 +2151,51 @@ _codecs_utf_32_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *errors = NULL;
int byteorder = 0;
- if (!_PyArg_ParseStack(args, nargs, "U|zi:utf_32_encode",
- &str, &errors, &byteorder)) {
+ if (!_PyArg_CheckPositional("utf_32_encode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_32_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_encode", 2, "str or None", args[1]);
goto exit;
}
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ byteorder = _PyLong_AsInt(args[2]);
+ if (byteorder == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_32_encode_impl(module, str, errors, byteorder);
exit:
@@ -1160,10 +2221,39 @@ _codecs_utf_32_le_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:utf_32_le_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("utf_32_le_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_32_le_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_le_encode", 2, "str or None", args[1]);
goto exit;
}
+skip_optional:
return_value = _codecs_utf_32_le_encode_impl(module, str, errors);
exit:
@@ -1189,10 +2279,39 @@ _codecs_utf_32_be_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:utf_32_be_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("utf_32_be_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("utf_32_be_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("utf_32_be_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_utf_32_be_encode_impl(module, str, errors);
exit:
@@ -1218,10 +2337,39 @@ _codecs_unicode_escape_encode(PyObject *module, PyObject *const *args, Py_ssize_
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:unicode_escape_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("unicode_escape_encode", nargs, 1, 2)) {
goto exit;
}
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("unicode_escape_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("unicode_escape_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_unicode_escape_encode_impl(module, str, errors);
exit:
@@ -1247,10 +2395,39 @@ _codecs_raw_unicode_escape_encode(PyObject *module, PyObject *const *args, Py_ss
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:raw_unicode_escape_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("raw_unicode_escape_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("raw_unicode_escape_encode", 1, "str", args[0]);
goto exit;
}
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("raw_unicode_escape_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_raw_unicode_escape_encode_impl(module, str, errors);
exit:
@@ -1276,10 +2453,39 @@ _codecs_latin_1_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:latin_1_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("latin_1_encode", nargs, 1, 2)) {
goto exit;
}
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("latin_1_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("latin_1_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_latin_1_encode_impl(module, str, errors);
exit:
@@ -1305,10 +2511,39 @@ _codecs_ascii_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:ascii_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("ascii_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("ascii_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("ascii_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_ascii_encode_impl(module, str, errors);
exit:
@@ -1335,10 +2570,43 @@ _codecs_charmap_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs
const char *errors = NULL;
PyObject *mapping = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|zO:charmap_encode",
- &str, &errors, &mapping)) {
+ if (!_PyArg_CheckPositional("charmap_encode", nargs, 1, 3)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("charmap_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("charmap_encode", 2, "str or None", args[1]);
goto exit;
}
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ mapping = args[2];
+skip_optional:
return_value = _codecs_charmap_encode_impl(module, str, errors, mapping);
exit:
@@ -1363,7 +2631,7 @@ _codecs_charmap_build(PyObject *module, PyObject *arg)
PyObject *map;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("charmap_build", "str", arg);
+ _PyArg_BadArgument("charmap_build", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -1396,10 +2664,39 @@ _codecs_mbcs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:mbcs_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("mbcs_encode", nargs, 1, 2)) {
goto exit;
}
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("mbcs_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("mbcs_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_mbcs_encode_impl(module, str, errors);
exit:
@@ -1428,10 +2725,39 @@ _codecs_oem_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "U|z:oem_encode",
- &str, &errors)) {
+ if (!_PyArg_CheckPositional("oem_encode", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("oem_encode", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
+ str = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("oem_encode", 2, "str or None", args[1]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_oem_encode_impl(module, str, errors);
exit:
@@ -1462,10 +2788,48 @@ _codecs_code_page_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar
PyObject *str;
const char *errors = NULL;
- if (!_PyArg_ParseStack(args, nargs, "iU|z:code_page_encode",
- &code_page, &str, &errors)) {
+ if (!_PyArg_CheckPositional("code_page_encode", nargs, 2, 3)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ code_page = _PyLong_AsInt(args[0]);
+ if (code_page == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[1])) {
+ _PyArg_BadArgument("code_page_encode", 2, "str", args[1]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
+ str = args[1];
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (args[2] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[2])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("code_page_encode", 3, "str or None", args[2]);
+ goto exit;
+ }
+skip_optional:
return_value = _codecs_code_page_encode_impl(module, code_page, str, errors);
exit:
@@ -1498,10 +2862,23 @@ _codecs_register_error(PyObject *module, PyObject *const *args, Py_ssize_t nargs
const char *errors;
PyObject *handler;
- if (!_PyArg_ParseStack(args, nargs, "sO:register_error",
- &errors, &handler)) {
+ if (!_PyArg_CheckPositional("register_error", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("register_error", 1, "str", args[0]);
+ goto exit;
+ }
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[0], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
+ handler = args[1];
return_value = _codecs_register_error_impl(module, errors, handler);
exit:
@@ -1530,7 +2907,7 @@ _codecs_lookup_error(PyObject *module, PyObject *arg)
const char *name;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("lookup_error", "str", arg);
+ _PyArg_BadArgument("lookup_error", 0, "str", arg);
goto exit;
}
Py_ssize_t name_length;
@@ -1571,4 +2948,4 @@ exit:
#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
#define _CODECS_CODE_PAGE_ENCODE_METHODDEF
#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
-/*[clinic end generated code: output=c2d2b917b78a4c45 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=85ea29db163ee74c input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_collectionsmodule.c.h b/Modules/clinic/_collectionsmodule.c.h
index 12626c1..ed3b1b5 100644
--- a/Modules/clinic/_collectionsmodule.c.h
+++ b/Modules/clinic/_collectionsmodule.c.h
@@ -16,13 +16,30 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("_tuplegetter", kwargs)) {
goto exit;
}
- if (!PyArg_ParseTuple(args, "nO:_tuplegetter",
- &index, &doc)) {
+ if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
goto exit;
}
+ if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 0));
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ index = ival;
+ }
+ doc = PyTuple_GET_ITEM(args, 1);
return_value = tuplegetter_new_impl(type, index, doc);
exit:
return return_value;
}
-/*[clinic end generated code: output=83746071eacc28d3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=51bd572577ca7111 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_cryptmodule.c.h b/Modules/clinic/_cryptmodule.c.h
index baa31e2..2fcb0c1 100644
--- a/Modules/clinic/_cryptmodule.c.h
+++ b/Modules/clinic/_cryptmodule.c.h
@@ -26,8 +26,33 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *word;
const char *salt;
- if (!_PyArg_ParseStack(args, nargs, "ss:crypt",
- &word, &salt)) {
+ if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("crypt", 1, "str", args[0]);
+ goto exit;
+ }
+ Py_ssize_t word_length;
+ word = PyUnicode_AsUTF8AndSize(args[0], &word_length);
+ if (word == NULL) {
+ goto exit;
+ }
+ if (strlen(word) != (size_t)word_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[1])) {
+ _PyArg_BadArgument("crypt", 2, "str", args[1]);
+ goto exit;
+ }
+ Py_ssize_t salt_length;
+ salt = PyUnicode_AsUTF8AndSize(args[1], &salt_length);
+ if (salt == NULL) {
+ goto exit;
+ }
+ if (strlen(salt) != (size_t)salt_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = crypt_crypt_impl(module, word, salt);
@@ -35,4 +60,4 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=79001dbfdd623ff9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3f75d4d4be4dddbb input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h
index 2e569c5..ed59c3b 100644
--- a/Modules/clinic/_curses_panel.c.h
+++ b/Modules/clinic/_curses_panel.c.h
@@ -149,8 +149,25 @@ _curses_panel_panel_move(PyCursesPanelObject *self, PyObject *const *args, Py_ss
int y;
int x;
- if (!_PyArg_ParseStack(args, nargs, "ii:move",
- &y, &x)) {
+ if (!_PyArg_CheckPositional("move", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ y = _PyLong_AsInt(args[0]);
+ if (y == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ x = _PyLong_AsInt(args[1]);
+ if (x == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_panel_panel_move_impl(self, y, x);
@@ -197,7 +214,7 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg)
PyCursesWindowObject *win;
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
- _PyArg_BadArgument("replace", (&PyCursesWindow_Type)->tp_name, arg);
+ _PyArg_BadArgument("replace", 0, (&PyCursesWindow_Type)->tp_name, arg);
goto exit;
}
win = (PyCursesWindowObject *)arg;
@@ -271,7 +288,7 @@ _curses_panel_new_panel(PyObject *module, PyObject *arg)
PyCursesWindowObject *win;
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
- _PyArg_BadArgument("new_panel", (&PyCursesWindow_Type)->tp_name, arg);
+ _PyArg_BadArgument("new_panel", 0, (&PyCursesWindow_Type)->tp_name, arg);
goto exit;
}
win = (PyCursesWindowObject *)arg;
@@ -318,4 +335,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _curses_panel_update_panels_impl(module);
}
-/*[clinic end generated code: output=4b211b4015e29100 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ac1f56e6c3d4cc57 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h
index 01c7097..0988581 100644
--- a/Modules/clinic/_cursesmodule.c.h
+++ b/Modules/clinic/_cursesmodule.c.h
@@ -245,10 +245,23 @@ _curses_window_bkgd(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_
PyObject *ch;
long attr = A_NORMAL;
- if (!_PyArg_ParseStack(args, nargs, "O|l:bkgd",
- &ch, &attr)) {
+ if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) {
goto exit;
}
+ ch = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = PyLong_AsLong(args[1]);
+ if (attr == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _curses_window_bkgd_impl(self, ch, attr);
exit:
@@ -379,10 +392,23 @@ _curses_window_bkgdset(PyCursesWindowObject *self, PyObject *const *args, Py_ssi
PyObject *ch;
long attr = A_NORMAL;
- if (!_PyArg_ParseStack(args, nargs, "O|l:bkgdset",
- &ch, &attr)) {
+ if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) {
+ goto exit;
+ }
+ ch = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = PyLong_AsLong(args[1]);
+ if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _curses_window_bkgdset_impl(self, ch, attr);
exit:
@@ -623,10 +649,23 @@ _curses_window_echochar(PyCursesWindowObject *self, PyObject *const *args, Py_ss
PyObject *ch;
long attr = A_NORMAL;
- if (!_PyArg_ParseStack(args, nargs, "O|l:echochar",
- &ch, &attr)) {
+ if (!_PyArg_CheckPositional("echochar", nargs, 1, 2)) {
+ goto exit;
+ }
+ ch = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = PyLong_AsLong(args[1]);
+ if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _curses_window_echochar_impl(self, ch, attr);
exit:
@@ -660,8 +699,25 @@ _curses_window_enclose(PyCursesWindowObject *self, PyObject *const *args, Py_ssi
int x;
long _return_value;
- if (!_PyArg_ParseStack(args, nargs, "ii:enclose",
- &y, &x)) {
+ if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ y = _PyLong_AsInt(args[0]);
+ if (y == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ x = _PyLong_AsInt(args[1]);
+ if (x == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _curses_window_enclose_impl(self, y, x);
@@ -1462,8 +1518,25 @@ _curses_window_redrawln(PyCursesWindowObject *self, PyObject *const *args, Py_ss
int beg;
int num;
- if (!_PyArg_ParseStack(args, nargs, "ii:redrawln",
- &beg, &num)) {
+ if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ beg = _PyLong_AsInt(args[0]);
+ if (beg == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ num = _PyLong_AsInt(args[1]);
+ if (num == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_redrawln_impl(self, beg, num);
@@ -1554,8 +1627,25 @@ _curses_window_setscrreg(PyCursesWindowObject *self, PyObject *const *args, Py_s
int top;
int bottom;
- if (!_PyArg_ParseStack(args, nargs, "ii:setscrreg",
- &top, &bottom)) {
+ if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ top = _PyLong_AsInt(args[0]);
+ if (top == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ bottom = _PyLong_AsInt(args[1]);
+ if (bottom == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_setscrreg_impl(self, top, bottom);
@@ -1878,10 +1968,22 @@ _curses_cbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
- if (!_PyArg_ParseStack(args, nargs, "|i:cbreak",
- &flag)) {
+ if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(args[0]);
+ if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _curses_cbreak_impl(module, flag);
exit:
@@ -2158,10 +2260,22 @@ _curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
- if (!_PyArg_ParseStack(args, nargs, "|i:echo",
- &flag)) {
+ if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(args[0]);
+ if (flag == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _curses_echo_impl(module, flag);
exit:
@@ -2321,10 +2435,65 @@ _curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int z;
unsigned long bstate;
- if (!_PyArg_ParseStack(args, nargs, "hiiik:ungetmouse",
- &id, &x, &y, &z, &bstate)) {
+ if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(args[0]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ id = (short) ival;
+ }
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ x = _PyLong_AsInt(args[1]);
+ if (x == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ y = _PyLong_AsInt(args[2]);
+ if (y == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[3])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ z = _PyLong_AsInt(args[3]);
+ if (z == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (!PyLong_Check(args[4])) {
+ _PyArg_BadArgument("ungetmouse", 5, "int", args[4]);
+ goto exit;
+ }
+ bstate = PyLong_AsUnsignedLongMask(args[4]);
return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate);
exit:
@@ -2527,10 +2696,105 @@ _curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
short g;
short b;
- if (!_PyArg_ParseStack(args, nargs, "hhhh:init_color",
- &color_number, &r, &g, &b)) {
+ if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsLong(args[0]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ color_number = (short) ival;
+ }
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsLong(args[1]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ r = (short) ival;
+ }
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsLong(args[2]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ g = (short) ival;
+ }
+ }
+ if (PyFloat_Check(args[3])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(args[3]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ b = (short) ival;
+ }
+ }
return_value = _curses_init_color_impl(module, color_number, r, g, b);
exit:
@@ -2568,10 +2832,81 @@ _curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
short fg;
short bg;
- if (!_PyArg_ParseStack(args, nargs, "hhh:init_pair",
- &pair_number, &fg, &bg)) {
+ if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsLong(args[0]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ pair_number = (short) ival;
+ }
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ {
+ long ival = PyLong_AsLong(args[1]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ fg = (short) ival;
+ }
+ }
+ if (PyFloat_Check(args[2])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(args[2]);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ bg = (short) ival;
+ }
+ }
return_value = _curses_init_pair_impl(module, pair_number, fg, bg);
exit:
@@ -2712,8 +3047,25 @@ _curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t narg
int nlines;
int ncols;
- if (!_PyArg_ParseStack(args, nargs, "ii:is_term_resized",
- &nlines, &ncols)) {
+ if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ nlines = _PyLong_AsInt(args[0]);
+ if (nlines == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ ncols = _PyLong_AsInt(args[1]);
+ if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_is_term_resized_impl(module, nlines, ncols);
@@ -2905,7 +3257,7 @@ _curses_mousemask(PyObject *module, PyObject *arg)
unsigned long newmask;
if (!PyLong_Check(arg)) {
- _PyArg_BadArgument("mousemask", "int", arg);
+ _PyArg_BadArgument("mousemask", 0, "int", arg);
goto exit;
}
newmask = PyLong_AsUnsignedLongMask(arg);
@@ -2977,8 +3329,25 @@ _curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines;
int ncols;
- if (!_PyArg_ParseStack(args, nargs, "ii:newpad",
- &nlines, &ncols)) {
+ if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ nlines = _PyLong_AsInt(args[0]);
+ if (nlines == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ ncols = _PyLong_AsInt(args[1]);
+ if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_newpad_impl(module, nlines, ncols);
@@ -3066,10 +3435,22 @@ _curses_nl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
- if (!_PyArg_ParseStack(args, nargs, "|i:nl",
- &flag)) {
+ if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(args[0]);
+ if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _curses_nl_impl(module, flag);
exit:
@@ -3317,10 +3698,22 @@ _curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
- if (!_PyArg_ParseStack(args, nargs, "|i:qiflush",
- &flag)) {
+ if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(args[0]);
+ if (flag == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _curses_qiflush_impl(module, flag);
exit:
@@ -3383,10 +3776,22 @@ _curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
- if (!_PyArg_ParseStack(args, nargs, "|i:raw",
- &flag)) {
+ if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(args[0]);
+ if (flag == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = _curses_raw_impl(module, flag);
exit:
@@ -3476,8 +3881,25 @@ _curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines;
int ncols;
- if (!_PyArg_ParseStack(args, nargs, "ii:resizeterm",
- &nlines, &ncols)) {
+ if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ nlines = _PyLong_AsInt(args[0]);
+ if (nlines == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ ncols = _PyLong_AsInt(args[1]);
+ if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_resizeterm_impl(module, nlines, ncols);
@@ -3520,8 +3942,25 @@ _curses_resize_term(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines;
int ncols;
- if (!_PyArg_ParseStack(args, nargs, "ii:resize_term",
- &nlines, &ncols)) {
+ if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ nlines = _PyLong_AsInt(args[0]);
+ if (nlines == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ ncols = _PyLong_AsInt(args[1]);
+ if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_resize_term_impl(module, nlines, ncols);
@@ -3578,8 +4017,25 @@ _curses_setsyx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int y;
int x;
- if (!_PyArg_ParseStack(args, nargs, "ii:setsyx",
- &y, &x)) {
+ if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ y = _PyLong_AsInt(args[0]);
+ if (y == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ x = _PyLong_AsInt(args[1]);
+ if (x == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_setsyx_impl(module, y, x);
@@ -3676,7 +4132,7 @@ _curses_tigetflag(PyObject *module, PyObject *arg)
const char *capname;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("tigetflag", "str", arg);
+ _PyArg_BadArgument("tigetflag", 0, "str", arg);
goto exit;
}
Py_ssize_t capname_length;
@@ -3719,7 +4175,7 @@ _curses_tigetnum(PyObject *module, PyObject *arg)
const char *capname;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("tigetnum", "str", arg);
+ _PyArg_BadArgument("tigetnum", 0, "str", arg);
goto exit;
}
Py_ssize_t capname_length;
@@ -3762,7 +4218,7 @@ _curses_tigetstr(PyObject *module, PyObject *arg)
const char *capname;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("tigetstr", "str", arg);
+ _PyArg_BadArgument("tigetstr", 0, "str", arg);
goto exit;
}
Py_ssize_t capname_length;
@@ -4044,4 +4500,4 @@ _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=a2bbced3c5d29d64 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ceb2e32ee1370033 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_dbmmodule.c.h b/Modules/clinic/_dbmmodule.c.h