mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Py_BuildValue's 'c' code should use byte strings #5666
This commit is contained in:
parent
a3b1ac8dca
commit
a921fb0f66
4 changed files with 11 additions and 7 deletions
|
@ -212,7 +212,7 @@ variable(s) whose address should be passed.
|
||||||
:ctype:`char`.
|
:ctype:`char`.
|
||||||
|
|
||||||
``C`` (string of length 1) [int]
|
``C`` (string of length 1) [int]
|
||||||
Covert a Python character, represented as a unicode string of length 1, to a
|
Convert a Python character, represented as a unicode string of length 1, to a
|
||||||
C :ctype:`int`.
|
C :ctype:`int`.
|
||||||
|
|
||||||
``f`` (float) [float]
|
``f`` (float) [float]
|
||||||
|
@ -511,8 +511,12 @@ and the following format units are left untouched.
|
||||||
Convert a C :ctype:`Py_ssize_t` to a Python integer.
|
Convert a C :ctype:`Py_ssize_t` to a Python integer.
|
||||||
|
|
||||||
``c`` (string of length 1) [char]
|
``c`` (string of length 1) [char]
|
||||||
Convert a C :ctype:`int` representing a character to a Python string of length
|
Convert a C :ctype:`int` representing a byte to a Python byte string of
|
||||||
1.
|
length 1.
|
||||||
|
|
||||||
|
``C`` (string of length 1) [int]
|
||||||
|
Convert a C :ctype:`int` representing a character to Python unicode
|
||||||
|
string of length 1.
|
||||||
|
|
||||||
``d`` (float) [double]
|
``d`` (float) [double]
|
||||||
Convert a C :ctype:`double` to a Python floating point number.
|
Convert a C :ctype:`double` to a Python floating point number.
|
||||||
|
|
|
@ -890,7 +890,7 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
|
||||||
PyErr_SetString(PyCursesError, "no input");
|
PyErr_SetString(PyCursesError, "no input");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (rtn<=255)
|
} else if (rtn<=255)
|
||||||
return Py_BuildValue("c", rtn);
|
return Py_BuildValue("C", rtn);
|
||||||
else
|
else
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
return PyUnicode_FromString(unctrl(rtn));
|
return PyUnicode_FromString(unctrl(rtn));
|
||||||
|
|
|
@ -1141,14 +1141,14 @@ array_reduce(arrayobject *array)
|
||||||
> PY_SSIZE_T_MAX / Py_SIZE(array)) {
|
> PY_SSIZE_T_MAX / Py_SIZE(array)) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
result = Py_BuildValue("O(cy#)O",
|
result = Py_BuildValue("O(Cy#)O",
|
||||||
Py_TYPE(array),
|
Py_TYPE(array),
|
||||||
array->ob_descr->typecode,
|
array->ob_descr->typecode,
|
||||||
array->ob_item,
|
array->ob_item,
|
||||||
Py_SIZE(array) * array->ob_descr->itemsize,
|
Py_SIZE(array) * array->ob_descr->itemsize,
|
||||||
dict);
|
dict);
|
||||||
} else {
|
} else {
|
||||||
result = Py_BuildValue("O(c)O",
|
result = Py_BuildValue("O(C)O",
|
||||||
Py_TYPE(array),
|
Py_TYPE(array),
|
||||||
array->ob_descr->typecode,
|
array->ob_descr->typecode,
|
||||||
dict);
|
dict);
|
||||||
|
|
|
@ -289,7 +289,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
||||||
{
|
{
|
||||||
char p[1];
|
char p[1];
|
||||||
p[0] = (char)va_arg(*p_va, int);
|
p[0] = (char)va_arg(*p_va, int);
|
||||||
return PyUnicode_FromStringAndSize(p, 1);
|
return PyBytes_FromStringAndSize(p, 1);
|
||||||
}
|
}
|
||||||
case 'C':
|
case 'C':
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue