Issue #28511: Use the "U" format instead of "O!" in PyArg_Parse*.
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index bc0264a..57a786c 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -1820,18 +1820,10 @@
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 @@
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 @@
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;
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index af95bb6..6ab691f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8621,7 +8621,7 @@
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 @@
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;