Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
This commit is contained in:
parent
fa68a6188a
commit
7eeb5b5e50
|
@ -530,12 +530,10 @@ Building values
|
|||
and ``None`` is returned.
|
||||
|
||||
``U`` (string) [char \*]
|
||||
Convert a null-terminated C string to a Python unicode object. If the C string
|
||||
pointer is *NULL*, ``None`` is used.
|
||||
Same as ``s``.
|
||||
|
||||
``U#`` (string) [char \*, int]
|
||||
Convert a C string and its length to a Python unicode object. If the C string
|
||||
pointer is *NULL*, the length is ignored and ``None`` is returned.
|
||||
Same as ``s#``.
|
||||
|
||||
``i`` (integer) [int]
|
||||
Convert a plain C :ctype:`int` to a Python integer object.
|
||||
|
|
|
@ -4467,7 +4467,7 @@ PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length)
|
|||
#endif
|
||||
|
||||
result = PyObject_CallFunction((PyObject *)&PyCArrayType_Type,
|
||||
"U(O){s:n,s:O}",
|
||||
"s(O){s:n,s:O}",
|
||||
name,
|
||||
&PyCArray_Type,
|
||||
"_length_",
|
||||
|
|
|
@ -1510,7 +1510,7 @@ PyUnicodeEncodeError_Create(
|
|||
const char *encoding, const Py_UNICODE *object, Py_ssize_t length,
|
||||
Py_ssize_t start, Py_ssize_t end, const char *reason)
|
||||
{
|
||||
return PyObject_CallFunction(PyExc_UnicodeEncodeError, "Uu#nnU",
|
||||
return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns",
|
||||
encoding, object, length, start, end, reason);
|
||||
}
|
||||
|
||||
|
@ -1625,7 +1625,7 @@ PyUnicodeDecodeError_Create(
|
|||
assert(length < INT_MAX);
|
||||
assert(start < INT_MAX);
|
||||
assert(end < INT_MAX);
|
||||
return PyObject_CallFunction(PyExc_UnicodeDecodeError, "Uy#nnU",
|
||||
return PyObject_CallFunction(PyExc_UnicodeDecodeError, "sy#nns",
|
||||
encoding, object, length, start, end, reason);
|
||||
}
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
|
|||
}
|
||||
PyTuple_SET_ITEM(fnames, i, field);
|
||||
}
|
||||
result = PyObject_CallFunction((PyObject*)&PyType_Type, "U(O){sOss}",
|
||||
result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
|
||||
type, base, "_fields", fnames, "__module__", "_ast");
|
||||
Py_DECREF(fnames);
|
||||
return (PyTypeObject*)result;
|
||||
|
|
|
@ -679,7 +679,7 @@ PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
|
|||
goto failure;
|
||||
}
|
||||
/* Create a real new-style class. */
|
||||
result = PyObject_CallFunction((PyObject *)&PyType_Type, "UOO",
|
||||
result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO",
|
||||
dot+1, bases, dict);
|
||||
failure:
|
||||
Py_XDECREF(bases);
|
||||
|
|
|
@ -302,39 +302,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
|||
|
||||
case 's':
|
||||
case 'z':
|
||||
{
|
||||
PyObject *v;
|
||||
char *str = va_arg(*p_va, char *);
|
||||
Py_ssize_t n;
|
||||
if (**p_format == '#') {
|
||||
++*p_format;
|
||||
if (flags & FLAG_SIZE_T)
|
||||
n = va_arg(*p_va, Py_ssize_t);
|
||||
else
|
||||
n = va_arg(*p_va, int);
|
||||
}
|
||||
else
|
||||
n = -1;
|
||||
if (str == NULL) {
|
||||
v = Py_None;
|
||||
Py_INCREF(v);
|
||||
}
|
||||
else {
|
||||
if (n < 0) {
|
||||
size_t m = strlen(str);
|
||||
if (m > PY_SSIZE_T_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"string too long for Python string");
|
||||
return NULL;
|
||||
}
|
||||
n = (Py_ssize_t)m;
|
||||
}
|
||||
v = PyUnicode_FromStringAndSize(str, n);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
case 'U':
|
||||
case 'U': /* XXX deprecated alias */
|
||||
{
|
||||
PyObject *v;
|
||||
char *str = va_arg(*p_va, char *);
|
||||
|
|
|
@ -1510,7 +1510,7 @@ _PySys_Init(void)
|
|||
PyLong_FromLong(PY_VERSION_HEX));
|
||||
svnversion_init();
|
||||
SET_SYS_FROM_STRING("subversion",
|
||||
Py_BuildValue("(UUU)", "CPython", branch,
|
||||
Py_BuildValue("(sss)", "CPython", branch,
|
||||
svn_revision));
|
||||
SET_SYS_FROM_STRING("dont_write_bytecode",
|
||||
PyBool_FromLong(Py_DontWriteBytecodeFlag));
|
||||
|
|
Loading…
Reference in New Issue