diff options
author | Georg Brandl <georg@python.org> | 2006-11-30 22:46:03 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-11-30 22:46:03 (GMT) |
commit | 16f3e03283cdbea6101d21960743d3901ddf8d57 (patch) | |
tree | 8a4bee86cfca8e5e502dd5b654b2aad11664fb52 | |
parent | 343435146a48d7922041a37bbd714fe5291523ff (diff) | |
download | cpython-16f3e03283cdbea6101d21960743d3901ddf8d57.zip cpython-16f3e03283cdbea6101d21960743d3901ddf8d57.tar.gz cpython-16f3e03283cdbea6101d21960743d3901ddf8d57.tar.bz2 |
Check "sep" and "end" for stringness in Print().
-rw-r--r-- | Python/bltinmodule.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 1a91296..8d7147b 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1429,7 +1429,20 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds) if (file == NULL || file == Py_None) 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++) { if (i > 0) { |