classification
Title: _pickle should implement the module finalisation protocol
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: alexandre.vassalotti Nosy List: Trundle, alexandre.vassalotti, benjamin.peterson, ncoghlan, pitrou, vstinner
Priority: normal Keywords:

Created on 2011-02-28 01:29 by ncoghlan, last changed 2013-12-01 21:52 by alexandre.vassalotti. This issue is now closed.

Messages (8)
msg129677 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-02-28 01:29
As discussed in issue11321, _pickle allocates a number of module level objects, but doesn't use the appropriate PEP 3121 mechanisms to manage their lifecycle.

It should be updated to follow the relevant development guidelines in the documentation.
msg129679 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-02-28 03:09
Unfortunately "proper" module finalization is an invitation to more segfaults because modules can be finalized before objects in them are, resulting in segfaults when its attempted to access modules.
msg129728 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-02-28 22:25
In that case, the request should probably read "_pickle should implement the module finalisation protocol, and module finalisation should be designed so that doing so isn't a recipe for segfaults".

It strikes me as being very similar to the existing problems we have with modules setting everything to None during shutdown, so my estimation of the difficulty of this request has risen accordingly :P
msg129730 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-02-28 22:43
It's a chicken and egg problem because proper module finalization techniques like #812369 are bogged down by static globals in extension modules, and proper state storage in modules is prevented by proper module finalization.
msg129748 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-03-01 09:34
We might be able to tapdance our way around the issue by falling back to the old mechanism when dealing with extension modules without traverse/clear/dealloc methods.
msg129749 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-01 09:51
Not sure why #812369 is bogged down. The patch simply needs updating for 3.x.
msg129774 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-03-01 14:11
http://mail.python.org/pipermail/python-dev/2009-October/093057.html

2011/3/1 Antoine Pitrou <report@bugs.python.org>:
>
> Antoine Pitrou <pitrou@free.fr> added the comment:
>
> Not sure why #812369 is bogged down. The patch simply needs updating for 3.x.
>
> ----------
> nosy: +pitrou
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue11349>
> _______________________________________
>
msg204971 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2013-12-01 21:52
I have implemented PEP 3121 module finalization for _pickle in 64c6d52793be.
History
Date User Action Args
2013-12-01 21:52:09alexandre.vassalottisetstatus: open -> closed

assignee: alexandre.vassalotti

nosy: + alexandre.vassalotti
messages: + msg204971
resolution: fixed
stage: needs patch -> resolved
2011-05-09 21:54:11vstinnersetnosy: + vstinner
2011-03-01 14:11:30benjamin.petersonsetnosy: ncoghlan, pitrou, benjamin.peterson, Trundle
messages: + msg129774
2011-03-01 09:51:23pitrousetnosy: + pitrou
messages: + msg129749
2011-03-01 09:34:02ncoghlansetnosy: ncoghlan, benjamin.peterson, Trundle
messages: + msg129748
2011-02-28 22:43:39benjamin.petersonsetnosy: ncoghlan, benjamin.peterson, Trundle
messages: + msg129730
2011-02-28 22:25:12ncoghlansettype: behavior -> enhancement
messages: + msg129728
nosy: ncoghlan, benjamin.peterson, Trundle
2011-02-28 03:09:49benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg129679
2011-02-28 01:30:29Trundlesetnosy: + Trundle
2011-02-28 01:29:10ncoghlancreate