[Python-checkins] bpo-20602: Do not clear sys.flags and sys.float_info during shutdown (GH-8096)
Petr Viktorin
webhook-mailer at python.org
Thu May 30 07:08:36 EDT 2019
https://github.com/python/cpython/commit/249b7d59d8038f9017fc95dc28a3ce3494aaf832
commit: 249b7d59d8038f9017fc95dc28a3ce3494aaf832
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: Petr Viktorin <pviktori at redhat.com>
date: 2019-05-30T13:08:24+02:00
summary:
bpo-20602: Do not clear sys.flags and sys.float_info during shutdown (GH-8096)
There is no need to clear these immutable objects during shutdown.
files:
A Misc/NEWS.d/next/Core and Builtins/2018-07-04-16-57-59.bpo-20602.sDLElw.rst
M Lib/test/test_sys.py
M Python/import.c
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index c558d116e6fe..49f2722d9514 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -822,6 +822,22 @@ def __del__(self):
rc, stdout, stderr = assert_python_ok('-c', code)
self.assertEqual(stdout.rstrip(), b'True')
+ @test.support.requires_type_collecting
+ def test_issue20602(self):
+ # sys.flags and sys.float_info were wiped during shutdown.
+ code = """if 1:
+ import sys
+ class A:
+ def __del__(self, sys=sys):
+ print(sys.flags)
+ print(sys.float_info)
+ a = A()
+ """
+ rc, out, err = assert_python_ok('-c', code)
+ out = out.splitlines()
+ self.assertIn(b'sys.flags', out[0])
+ self.assertIn(b'sys.float_info', out[1])
+
@unittest.skipUnless(hasattr(sys, 'getandroidapilevel'),
'need sys.getandroidapilevel()')
def test_getandroidapilevel(self):
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-07-04-16-57-59.bpo-20602.sDLElw.rst b/Misc/NEWS.d/next/Core and Builtins/2018-07-04-16-57-59.bpo-20602.sDLElw.rst
new file mode 100644
index 000000000000..ab37a020d803
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-07-04-16-57-59.bpo-20602.sDLElw.rst
@@ -0,0 +1,2 @@
+Do not clear :data:`sys.flags` and :data:`sys.float_info` during shutdown.
+Patch by Zackery Spytz.
diff --git a/Python/import.c b/Python/import.c
index 41a5c01cadf3..ab7db6bc17f6 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -383,8 +383,6 @@ static const char * const sys_deletes[] = {
"last_type", "last_value", "last_traceback",
"path_hooks", "path_importer_cache", "meta_path",
"__interactivehook__",
- /* misc stuff */
- "flags", "float_info",
NULL
};
More information about the Python-checkins
mailing list