mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Check "sep" and "end" for stringness in Print().
This commit is contained in:
parent
343435146a
commit
16f3e03283
1 changed files with 14 additions and 1 deletions
|
@ -1429,7 +1429,20 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
if (file == NULL || file == Py_None)
|
if (file == NULL || file == Py_None)
|
||||||
file = PySys_GetObject("stdout");
|
file = PySys_GetObject("stdout");
|
||||||
|
|
||||||
/* XXX Verify that sep and end are None, NULL or strings. */
|
if (sep && sep != Py_None && !PyString_Check(sep) &&
|
||||||
|
!PyUnicode_Check(sep)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"sep must be None, str or unicode, not %.200s",
|
||||||
|
sep->ob_type->tp_name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (end && end != Py_None && !PyString_Check(end) &&
|
||||||
|
!PyUnicode_Check(end)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"end must be None, str or unicode, not %.200s",
|
||||||
|
end->ob_type->tp_name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < PyTuple_Size(args); i++) {
|
for (i = 0; i < PyTuple_Size(args); i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue