diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/clinic/bytearrayobject.c.h | 13 | ||||
-rw-r--r-- | Objects/clinic/bytesobject.c.h | 21 | ||||
-rw-r--r-- | Objects/clinic/floatobject.c.h | 21 | ||||
-rw-r--r-- | Objects/clinic/longobject.c.h | 9 | ||||
-rw-r--r-- | Objects/clinic/typeobject.c.h | 17 | ||||
-rw-r--r-- | Objects/clinic/unicodeobject.c.h | 25 | ||||
-rw-r--r-- | Objects/stringlib/clinic/transmogrify.h.h | 18 |
7 files changed, 103 insertions, 21 deletions
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index f21353a..ec35eef 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -354,7 +354,7 @@ bytearray_append(PyByteArrayObject *self, PyObject *arg) PyObject *return_value = NULL; int item; - if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item)) { + if (!_getbytevalue(arg, &item)) { goto exit; } return_value = bytearray_append_impl(self, item); @@ -430,7 +430,7 @@ bytearray_remove(PyByteArrayObject *self, PyObject *arg) PyObject *return_value = NULL; int value; - if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value)) { + if (!_getbytevalue(arg, &value)) { goto exit; } return_value = bytearray_remove_impl(self, value); @@ -640,9 +640,14 @@ bytearray_fromhex(PyTypeObject *type, PyObject *arg) PyObject *return_value = NULL; PyObject *string; - if (!PyArg_Parse(arg, "U:fromhex", &string)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("fromhex", "str", arg); goto exit; } + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + string = arg; return_value = bytearray_fromhex_impl(type, string); exit: @@ -712,4 +717,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=b88bb192dddca6e1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cd3e13a1905a473c input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index 193d534..1345b64 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -66,7 +66,11 @@ bytes_partition(PyBytesObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer sep = {NULL, NULL}; - if (!PyArg_Parse(arg, "y*:partition", &sep)) { + if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&sep, 'C')) { + _PyArg_BadArgument("partition", "contiguous buffer", arg); goto exit; } return_value = bytes_partition_impl(self, &sep); @@ -105,7 +109,11 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer sep = {NULL, NULL}; - if (!PyArg_Parse(arg, "y*:rpartition", &sep)) { + if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&sep, 'C')) { + _PyArg_BadArgument("rpartition", "contiguous buffer", arg); goto exit; } return_value = bytes_rpartition_impl(self, &sep); @@ -491,12 +499,17 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) PyObject *return_value = NULL; PyObject *string; - if (!PyArg_Parse(arg, "U:fromhex", &string)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("fromhex", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } + string = arg; return_value = bytes_fromhex_impl(type, string); exit: return return_value; } -/*[clinic end generated code: output=07b33ac65362301b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=dc9aa04f0007ab11 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h index 8ff2a2b..28b24d0 100644 --- a/Objects/clinic/floatobject.c.h +++ b/Objects/clinic/floatobject.c.h @@ -228,7 +228,17 @@ float___getformat__(PyTypeObject *type, PyObject *arg) PyObject *return_value = NULL; const char *typestr; - if (!PyArg_Parse(arg, "s:__getformat__", &typestr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__getformat__", "str", arg); + goto exit; + } + Py_ssize_t typestr_length; + typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length); + if (typestr == NULL) { + goto exit; + } + if (strlen(typestr) != (size_t)typestr_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } return_value = float___getformat___impl(type, typestr); @@ -297,12 +307,17 @@ float___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyArg_Parse(arg, "U:__format__", &format_spec)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } + format_spec = arg; return_value = float___format___impl(self, format_spec); exit: return return_value; } -/*[clinic end generated code: output=091dd499f5386a6c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/ diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h index 3c33993..27cdf9e 100644 --- a/Objects/clinic/longobject.c.h +++ b/Objects/clinic/longobject.c.h @@ -58,9 +58,14 @@ int___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyArg_Parse(arg, "U:__format__", &format_spec)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "str", arg); goto exit; } + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + format_spec = arg; return_value = int___format___impl(self, format_spec); exit: @@ -239,4 +244,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb exit: return return_value; } -/*[clinic end generated code: output=403ccd096555fd1e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7436b5f4decdcf9d input=a9049054013a1b77]*/ diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h index 2760065..115a218 100644 --- a/Objects/clinic/typeobject.c.h +++ b/Objects/clinic/typeobject.c.h @@ -166,7 +166,13 @@ object___reduce_ex__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int protocol; - if (!PyArg_Parse(arg, "i:__reduce_ex__", &protocol)) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + protocol = _PyLong_AsInt(arg); + if (protocol == -1 && PyErr_Occurred()) { goto exit; } return_value = object___reduce_ex___impl(self, protocol); @@ -193,9 +199,14 @@ object___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyArg_Parse(arg, "U:__format__", &format_spec)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } + format_spec = arg; return_value = object___format___impl(self, format_spec); exit: @@ -237,4 +248,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return object___dir___impl(self); } -/*[clinic end generated code: output=8c4c856859564eaa input=a9049054013a1b77]*/ +/*[clinic end generated code: output=09f3453839e60136 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index 273ae92..744a6eb 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -898,9 +898,23 @@ unicode_zfill(PyObject *self, PyObject *arg) PyObject *return_value = NULL; Py_ssize_t width; - if (!PyArg_Parse(arg, "n:zfill", &width)) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(arg); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + width = ival; + } return_value = unicode_zfill_impl(self, width); exit: @@ -925,9 +939,14 @@ unicode___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyArg_Parse(arg, "U:__format__", &format_spec)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } + format_spec = arg; return_value = unicode___format___impl(self, format_spec); exit: @@ -951,4 +970,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored)) { return unicode_sizeof_impl(self); } -/*[clinic end generated code: output=d323802b67bfc6d8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ff6acd5abd1998eb input=a9049054013a1b77]*/ diff --git a/Objects/stringlib/clinic/transmogrify.h.h b/Objects/stringlib/clinic/transmogrify.h.h index fb63060..7b7fd58 100644 --- a/Objects/stringlib/clinic/transmogrify.h.h +++ b/Objects/stringlib/clinic/transmogrify.h.h @@ -147,12 +147,26 @@ stringlib_zfill(PyObject *self, PyObject *arg) PyObject *return_value = NULL; Py_ssize_t width; - if (!PyArg_Parse(arg, "n:zfill", &width)) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(arg); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + width = ival; + } return_value = stringlib_zfill_impl(self, width); exit: return return_value; } -/*[clinic end generated code: output=d09ba158d470566e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bf2ef501639e1190 input=a9049054013a1b77]*/ |