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.

classification
Title: Shelve references globals in its __del__ method
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Peter.Davies, berker.peksag, daniel.urban, petri.lehtinen, stutzbach
Priority: normal Keywords: needs review

Created on 2011-03-22 22:15 by Peter.Davies, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
shelve_del_fix.diff Peter.Davies, 2011-03-22 22:15 Fix which stores the globals in the shelf
Messages (4)
msg131793 - (view) Author: Peter Davies (Peter.Davies) Date: 2011-03-22 22:15
Shelf.__setitem__ (which is called from __del__ when writeback is enabled) references globals. This was causing exceptions on interpreter  shutdown (due to another exception) for me.

I have attached a patch which stores the relevant globals in the Shelf object.
msg141436 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-07-30 10:44
The patch looks good to me. Is there any way this could be tested in the test suite? How to simulate interpreter shutdown?
msg141524 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2011-08-01 16:20
Could you add a comment above the lines defining self._BytesIO, describing why they're being set?  Someone else might see them as unnecessary and rip them out if there's no explanation.

Can a test launch Python in a subprocess, set up the appropriate data structure, let the subprocess Python shutdown, then check the subprocess's stderr for the error?

It's a little convoluted, but perhaps it could be built into a general utility function that could be used to test __del__ methods in other modules, too.

Not sure that it's worth the effort though.
msg275925 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-12 02:43
Since PEP 442 has been implemented in 3.4 and e826940911c8 made Shelve.close() more robust, I think this is no longer an issue.
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55849
2016-09-12 02:43:11berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg275925

resolution: out of date
stage: patch review -> resolved
2013-02-06 18:17:53serhiy.storchakasetversions: + Python 3.4
2011-08-01 16:20:31stutzbachsetmessages: + msg141524
2011-07-30 10:44:37petri.lehtinensetnosy: + petri.lehtinen
messages: + msg141436

keywords: + needs review, - patch
stage: patch review
2011-03-25 17:30:11daniel.urbansetnosy: + daniel.urban
2011-03-22 22:41:36stutzbachsetnosy: + stutzbach

versions: + Python 3.3
2011-03-22 22:15:42Peter.Daviescreate