summaryrefslogtreecommitdiff
path: root/Python/traceback.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2015-02-04 01:04:31 -0800
committerGregory P. Smith <greg@krypto.org>2015-02-04 01:04:31 -0800
commitef3e7a803f7e575ce26cb2e4e29e46da2d89c124 (patch)
treeec9df5664c8029412e3923f694c3bbbbc9434ee6 /Python/traceback.c
parentf97d8cc43c09116bebd4d54b7ef5baf472058de3 (diff)
parent7c584647e0c2fe3f84299cab3b7941d1595de32f (diff)
downloadcpython-ef3e7a803f7e575ce26cb2e4e29e46da2d89c124.tar.gz
Skip some tests that require a subinterpreter launched with -E or -I when the
interpreter under test is being run in an environment that requires the use of environment variables such as PYTHONHOME in order to function at all. Adds a test.script_helper.interpreter_requires_environment() function to be used with @unittest.skipIf on stdlib test methods requiring this.
Diffstat (limited to 'Python/traceback.c')
-rw-r--r--Python/traceback.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index c2aba522bf..e3adc96ae8 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -231,7 +231,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;
@@ -575,15 +575,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);
}
@@ -678,7 +679,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");
}