summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/traceback.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index cdabd29..76280a3 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -396,6 +396,15 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent, i
if (filename == NULL)
return 0;
+ /* Do not attempt to open things like <string> or <stdin> */
+ assert(PyUnicode_Check(filename));
+ if (PyUnicode_READ_CHAR(filename, 0) == '<') {
+ Py_ssize_t len = PyUnicode_GET_LENGTH(filename);
+ if (len > 0 && PyUnicode_READ_CHAR(filename, len - 1) == '>') {
+ return 0;
+ }
+ }
+
io = PyImport_ImportModuleNoBlock("io");
if (io == NULL)
return -1;