From 0d41221156049e6fc5e6b861e2fc8f10ecdca784 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Tue, 5 Jun 2018 15:42:31 +0900 Subject: [PATCH 1/2] bpo-30167: Remove __cached__ when removing __file__ --- Python/pythonrun.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 26f74c80d032708..4d47b1fc3a1917f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -438,8 +438,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_DECREF(m); return ret; } From 5c013b7f496d4aadbd53274eee8f71f6163e25f0 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Tue, 5 Jun 2018 15:49:06 +0900 Subject: [PATCH 2/2] Add NEWS --- .../Core and Builtins/2018-06-05-15-49-02.bpo-30167.e956hA.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2018-06-05-15-49-02.bpo-30167.e956hA.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-06-05-15-49-02.bpo-30167.e956hA.rst b/Misc/NEWS.d/next/Core and Builtins/2018-06-05-15-49-02.bpo-30167.e956hA.rst new file mode 100644 index 000000000000000..41bdec899b75077 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2018-06-05-15-49-02.bpo-30167.e956hA.rst @@ -0,0 +1,2 @@ +``PyRun_SimpleFileExFlags`` removes ``__cached__`` from module in addition +to ``__file__``.