This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: sys.flags and sys.float_info disappear at shutdown
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, christian.heimes, petr.viktorin, pitrou, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2014-02-11 19:22 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit vstinner, 2015-03-09 09:31
Pull Requests
URL Status Linked Edit
PR 8096 merged ZackerySpytz, 2018-07-04 22:59
Messages (10)
msg211001 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-02-11 19:22
For some reason they are wiped to fix so-called reference leaks:

This changeset is one of the culprits of the problems in issue19255.
msg237604 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-09 08:41
I don't understand this bug report. Can you elaborate? What is the current behaviour? What is the expected behaviour?
msg237617 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-03-09 09:20
The behaviour is explained in the subject line and in the linked changeset: for some reason sys.flags and sys.float_info are explicitly wiped during shutdown. But those are simple immutable objects, there is no reason to wipe them.

The expected behaviour is, of course, that those objects keep their proper value during shutdown (e.g. when looked up from destructors).
msg237620 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-09 09:31 script to reproduce the issue.

The changeset 9639a73afa47 explicitly added sys.flags and sys.float_info to sys_deletes, list of symbols that must be cleared at exit.

So if I understand correctly the issue, the question is why the change was made. Antoine wants to keep these symbols alive during Python shutdown.
msg237621 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-09 09:32
@Antoine: Can you maybe propose a patch to fix this issue?

I see that you selected Python 3.4 & 3.5. Why Python 3.4 and not 2.7? (Maybe fixing Python 3.5 is enough?)
msg237622 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-03-09 09:32
I really don't care about 2.7 for minor fixes is the reason why :-)
(also, I don't know if the bug exists there in the first place)
msg321071 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2018-07-05 03:42
This behaviour is present in 2.7.
msg331426 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2018-12-09 12:34
msg343970 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2019-05-30 11:08
New changeset 249b7d59d8038f9017fc95dc28a3ce3494aaf832 by Petr Viktorin (Zackery Spytz) in branch 'master':
bpo-20602: Do not clear sys.flags and sys.float_info during shutdown (GH-8096)
msg344323 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-02 21:31
Honestly, I'm not sure that this issue is really a major bug. I don't think that it's worth it to backport the change. It's more a subtle change in Python finalization which is super fragile code. I prefer to only change the master branch, so I close the issue.
Date User Action Args
2022-04-11 14:57:58adminsetgithub: 64801
2019-06-02 21:31:33vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg344323

stage: patch review -> resolved
2019-05-30 11:08:36petr.viktorinsetnosy: + petr.viktorin
messages: + msg343970
2018-12-09 12:34:21ZackerySpytzsetmessages: + msg331426
2018-07-05 03:42:09ZackerySpytzsetnosy: + ZackerySpytz

messages: + msg321071
versions: + Python 2.7, Python 3.6, Python 3.7, Python 3.8, - Python 3.4, Python 3.5
2018-07-04 22:59:54ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request7695
2015-03-09 09:32:45pitrousetmessages: + msg237622
2015-03-09 09:32:05vstinnersetmessages: + msg237621
2015-03-09 09:31:24vstinnersetfiles: +

messages: + msg237620
2015-03-09 09:20:55pitrousetmessages: + msg237617
2015-03-09 08:41:41vstinnersetmessages: + msg237604
2015-03-09 08:26:32BreamoreBoysetversions: + Python 3.5
2014-02-12 17:45:23vstinnersetnosy: + vstinner
2014-02-11 19:22:01pitroucreate