From e61cceeeacea42566240bc7635bc8cc2f4168cf1 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 15 Aug 2014 23:30:40 +0200 Subject: Issue #22156: Fix "comparison between signed and unsigned integers" compiler warnings in the Python/ subdirectory. --- Python/traceback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/traceback.c') diff --git a/Python/traceback.c b/Python/traceback.c index 2ece192db9..565094b1e8 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -198,7 +198,7 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject * } strcpy(namebuf, PyBytes_AS_STRING(path)); Py_DECREF(path); - if (strlen(namebuf) != len) + if (strlen(namebuf) != (size_t)len) continue; /* v contains '\0' */ if (len > 0 && namebuf[len-1] != SEP) namebuf[len++] = SEP; -- cgit v1.2.1 From 877cbd7f86a2234c5b834a72d5425b81374921e9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 3 Oct 2014 14:18:09 +0200 Subject: faulthandler: enhance dump_ascii() to escape also non-printable ASCII characters (U+0000..U+001f and U+007f). --- Python/traceback.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Python/traceback.c') diff --git a/Python/traceback.c b/Python/traceback.c index 565094b1e8..5d60dade4c 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -541,15 +541,16 @@ dump_ascii(int fd, PyObject *text) ch = PyUnicode_READ(kind, data, i); else ch = wstr[i]; - if (ch < 128) { + if (' ' <= ch && ch <= 126) { + /* printable ASCII character */ char c = (char)ch; write(fd, &c, 1); } - else if (ch < 0xff) { + else if (ch <= 0xff) { PUTS(fd, "\\x"); dump_hexadecimal(fd, ch, 2); } - else if (ch < 0xffff) { + else if (ch <= 0xffff) { PUTS(fd, "\\u"); dump_hexadecimal(fd, ch, 4); } @@ -644,7 +645,7 @@ write_thread_id(int fd, PyThreadState *tstate, int is_current) PUTS(fd, "Current thread 0x"); else PUTS(fd, "Thread 0x"); - dump_hexadecimal(fd, (unsigned long)tstate->thread_id, sizeof(long)*2); + dump_hexadecimal(fd, (unsigned long)tstate->thread_id, sizeof(unsigned long)*2); PUTS(fd, " (most recent call first):\n"); } -- cgit v1.2.1