Commit 82daa60d authored by INADA Naoki's avatar INADA Naoki Committed by GitHub

bpo-30167: Remove __cached__ from __main__ when removing __file__ (GH-7415)

parent 9fbcfc08
``PyRun_SimpleFileExFlags`` removes ``__cached__`` from module in addition
to ``__file__``.
......@@ -434,8 +434,14 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
Py_DECREF(v);
ret = 0;
done:
if (set_file_name && PyDict_DelItemString(d, "__file__"))
PyErr_Clear();
if (set_file_name) {
if (PyDict_DelItemString(d, "__file__")) {
PyErr_Clear();
}
if (PyDict_DelItemString(d, "__cached__")) {
PyErr_Clear();
}
}
Py_XDECREF(m);
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment