Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
--- /dev/null
+Interpreter no longer attempts to open files with names in angle brackets (like "<string>" or "<stdin>") when formatting an exception.
\ No newline at end of file
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;