summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f87c53f..2970248 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -452,7 +452,7 @@ _PyRun_SimpleFileObject(FILE *fp, PyObject *filename, int closeit,
v = run_pyc_file(pyc_fp, dict, dict, flags);
} else {
/* When running from stdin, leave __main__.__loader__ alone */
- if (PyUnicode_CompareWithASCIIString(filename, "<stdin>") != 0 &&
+ if ((!PyUnicode_Check(filename) || !PyUnicode_EqualToUTF8(filename, "<stdin>")) &&
set_main_loader(dict, filename, "SourceFileLoader") < 0) {
fprintf(stderr, "python: failed to set __main__.__loader__\n");
ret = -1;
@@ -472,11 +472,11 @@ _PyRun_SimpleFileObject(FILE *fp, PyObject *filename, int closeit,
done:
if (set_file_name) {
- if (PyDict_DelItemString(dict, "__file__")) {
- PyErr_Clear();
+ if (PyDict_PopString(dict, "__file__", NULL) < 0) {
+ PyErr_Print();
}
- if (PyDict_DelItemString(dict, "__cached__")) {
- PyErr_Clear();
+ if (PyDict_PopString(dict, "__cached__", NULL) < 0) {
+ PyErr_Print();
}
}
Py_XDECREF(main_module);