]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #28511: Use the "U" format instead of "O!" in PyArg_Parse*.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 23 Oct 2016 12:12:25 +0000 (15:12 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 23 Oct 2016 12:12:25 +0000 (15:12 +0300)
Modules/_datetimemodule.c
Modules/clinic/unicodedata.c.h
Modules/unicodedata.c
Objects/exceptions.c
Objects/unicodeobject.c

index 5ddf6504c579df312fb0c28b8c431128e2e33d7c..cced71cd9ca5c29116bc082c385f539d4f8c137e 100644 (file)
@@ -3243,9 +3243,8 @@ timezone_new(PyTypeObject *type, PyObject *args, PyObject *kw)
 {
     PyObject *offset;
     PyObject *name = NULL;
-    if (PyArg_ParseTupleAndKeywords(args, kw, "O!|O!:timezone", timezone_kws,
-                                    &PyDateTime_DeltaType, &offset,
-                                    &PyUnicode_Type, &name))
+    if (PyArg_ParseTupleAndKeywords(args, kw, "O!|U:timezone", timezone_kws,
+                                    &PyDateTime_DeltaType, &offset, &name))
         return new_timezone(offset, name);
 
     return NULL;
index d481ccbe643fb8aa1651d4267683be3a6b31626e..e8a73b9c47d7ae8ccf5615075f10fa6111b92b57 100644 (file)
@@ -306,8 +306,8 @@ unicodedata_UCD_normalize(PyObject *self, PyObject *args)
     const char *form;
     PyObject *input;
 
-    if (!PyArg_ParseTuple(args, "sO!:normalize",
-        &form, &PyUnicode_Type, &input)) {
+    if (!PyArg_ParseTuple(args, "sU:normalize",
+        &form, &input)) {
         goto exit;
     }
     return_value = unicodedata_UCD_normalize_impl(self, form, input);
@@ -379,4 +379,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=5313ce129da87b2f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=07e93c267323a576 input=a9049054013a1b77]*/
index 9e71e018e21590230334c6012876109a16ac74ba..fbe811e807ad66cdba704d7cfacebe2d73ca88e2 100644 (file)
@@ -808,7 +808,7 @@ unicodedata.UCD.normalize
 
     self: self
     form: str
-    unistr as input: object(subclass_of='&PyUnicode_Type')
+    unistr as input: unicode
     /
 
 Return the normal form 'form' for the Unicode string unistr.
@@ -819,11 +819,8 @@ Valid values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
 static PyObject *
 unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
                                PyObject *input)
-/*[clinic end generated code: output=62d1f8870027efdc input=cd092e631cf11883]*/
+/*[clinic end generated code: output=62d1f8870027efdc input=1744c55f4ab79bf0]*/
 {
-    if (PyUnicode_READY(input) == -1)
-        return NULL;
-
     if (PyUnicode_GET_LENGTH(input) == 0) {
         /* Special case empty input strings, since resizing
            them  later would cause internal errors. */
index bc0264a5e9577c208a5bd07020cb3b4cf2d66283..57a786c0220458c4125849cfe037e6acd0fd3b75 100644 (file)
@@ -1820,18 +1820,10 @@ UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds)
     Py_CLEAR(err->object);
     Py_CLEAR(err->reason);
 
-    if (!PyArg_ParseTuple(args, "O!O!nnO!",
-        &PyUnicode_Type, &err->encoding,
-        &PyUnicode_Type, &err->object,
-        &err->start,
-        &err->end,
-        &PyUnicode_Type, &err->reason)) {
-          err->encoding = err->object = err->reason = NULL;
-          return -1;
-    }
-
-    if (PyUnicode_READY(err->object) < -1) {
-        err->encoding = NULL;
+    if (!PyArg_ParseTuple(args, "UUnnU",
+                          &err->encoding, &err->object,
+                          &err->start, &err->end, &err->reason)) {
+        err->encoding = err->object = err->reason = NULL;
         return -1;
     }
 
@@ -1935,12 +1927,9 @@ UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds)
     Py_CLEAR(ude->object);
     Py_CLEAR(ude->reason);
 
-    if (!PyArg_ParseTuple(args, "O!OnnO!",
-         &PyUnicode_Type, &ude->encoding,
-         &ude->object,
-         &ude->start,
-         &ude->end,
-         &PyUnicode_Type, &ude->reason)) {
+    if (!PyArg_ParseTuple(args, "UOnnU",
+                          &ude->encoding, &ude->object,
+                          &ude->start, &ude->end, &ude->reason)) {
              ude->encoding = ude->object = ude->reason = NULL;
              return -1;
     }
@@ -2050,11 +2039,9 @@ UnicodeTranslateError_init(PyUnicodeErrorObject *self, PyObject *args,
     Py_CLEAR(self->object);
     Py_CLEAR(self->reason);
 
-    if (!PyArg_ParseTuple(args, "O!nnO!",
-        &PyUnicode_Type, &self->object,
-        &self->start,
-        &self->end,
-        &PyUnicode_Type, &self->reason)) {
+    if (!PyArg_ParseTuple(args, "UnnU",
+                          &self->object,
+                          &self->start, &self->end, &self->reason)) {
         self->object = self->reason = NULL;
         return -1;
     }
index af95bb6b4a594524e15ae9d9b16d49b4d033efad..6ab691ff25a5a3cc03f402e5d51c7d34f64ab848 100644 (file)
@@ -8621,7 +8621,7 @@ unicode_translate_call_errorhandler(const char *errors,
                                     Py_ssize_t startpos, Py_ssize_t endpos,
                                     Py_ssize_t *newpos)
 {
-    static const char *argparse = "O!n;translating error handler must return (str, int) tuple";
+    static const char *argparse = "Un;translating error handler must return (str, int) tuple";
 
     Py_ssize_t i_newpos;
     PyObject *restuple;
@@ -8643,11 +8643,11 @@ unicode_translate_call_errorhandler(const char *errors,
     if (restuple == NULL)
         return NULL;
     if (!PyTuple_Check(restuple)) {
-        PyErr_SetString(PyExc_TypeError, &argparse[4]);
+        PyErr_SetString(PyExc_TypeError, &argparse[3]);
         Py_DECREF(restuple);
         return NULL;
     }
-    if (!PyArg_ParseTuple(restuple, argparse, &PyUnicode_Type,
+    if (!PyArg_ParseTuple(restuple, argparse,
                           &resunicode, &i_newpos)) {
         Py_DECREF(restuple);
         return NULL;