summaryrefslogtreecommitdiff
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-14 21:18:31 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-14 21:18:31 +0300
commitc1d9bb342c40ba1e7b0cf69214726d269f1d74db (patch)
treef971494fc467034d9f7ac082fc9930d76dde5764 /Python/getargs.c
parent8664b17c9457da72299bf05ca734b02c6cea00f1 (diff)
parentb0e630183e0663e0651c5d8fe54a15fb46699d0c (diff)
downloadcpython-c1d9bb342c40ba1e7b0cf69214726d269f1d74db.tar.gz
Issue #22384: An exception in Tkinter callback no longer crashes the program
when it is run with pythonw.exe. Documented that Tk.report_callback_exception() is purposed to be overriden in applications.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 946faf2d7e..c749bb643c 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -872,10 +872,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
STORE_SIZE(count);
format++;
} else {
- if (strlen(*p) != count)
- return converterr(
- "bytes without null bytes",
- arg, msgbuf, bufsize);
+ if (strlen(*p) != (size_t)count) {
+ PyErr_SetString(PyExc_ValueError, "embedded null byte");
+ RETURN_ERR_OCCURRED;
+ }
}
break;
}
@@ -948,16 +948,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (sarg == NULL)
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
+ if (strlen(sarg) != (size_t)len) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ RETURN_ERR_OCCURRED;
+ }
*p = sarg;
}
else
return converterr(c == 'z' ? "str or None" : "str",
arg, msgbuf, bufsize);
- if (*p != NULL && sarg != NULL && (Py_ssize_t) strlen(*p) != len)
- return converterr(
- c == 'z' ? "str without null characters or None"
- : "str without null characters",
- arg, msgbuf, bufsize);
}
break;
}
@@ -994,10 +993,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
*p = PyUnicode_AsUnicodeAndSize(arg, &len);
if (*p == NULL)
RETURN_ERR_OCCURRED;
- if (Py_UNICODE_strlen(*p) != len)
- return converterr(
- "str without null characters or None",
- arg, msgbuf, bufsize);
+ if (Py_UNICODE_strlen(*p) != (size_t)len) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ RETURN_ERR_OCCURRED;
+ }
} else
return converterr(c == 'Z' ? "str or None" : "str",
arg, msgbuf, bufsize);