msg164454 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2012-07-01 07:58 |
Currently, the atexit docs state "The order in which the functions are called is not defined" in the introduction and "all functions registered are called in last in, first out order" in the docs of the atexit() function. While the latter is correct, I don't think we should guarantee that behaviour by documenting it. Suggestions? |
|
|
msg164458 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2012-07-01 08:20 |
I believe it should be guaranteed behavior and that code may reasonably want to have a predictable sequence of unwinding behaviors. |
|
|
msg164471 - (view) |
Author: Charles-François Natali (neologix) *  |
Date: 2012-07-01 10:17 |
It is guaranteed by libc's atexit(3), and should also be guaranteed here. |
|
|
msg164472 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-01 10:20 |
+1 to guaranteeing the order. |
|
|
msg164475 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-07-01 11:27 |
> I believe it should be guaranteed behavior and that code may > reasonably want to have a predictable sequence of unwinding behaviors. Agreed. |
|
|
msg164516 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-02 14:24 |
Here's a patch. I read the implementation to find out what it does, then documented it. Happily it does the sane thing. |
|
|
msg164517 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-07-02 14:30 |
> Here's a patch. I read the implementation to find out what it does, > then documented it. Happily it does the sane thing. Is it tested for? |
|
|
msg164527 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2012-07-02 19:10 |
See #9788 for previous discussion. |
|
|
msg164555 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2012-07-02 21:34 |
The patch wording is fine. However, I would avoid the "note" markup. It is visually distracting and there isn't a reason to pull this out of the main text. |
|
|
msg164579 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-03 06:26 |
> Is it tested for? Amusingly enough, yes. test_order() in Lib/test/test_atexit.py already ensures reverse order. |
|
|
msg164581 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-03 06:51 |
> I would avoid the "note" markup. It is visually distracting > and there isn't a reason to pull this out of the main text. I think it's an improvement; it helps draw the eye to an important warning. Does anyone else have an opinion one way or another? |
|
|
msg164588 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-07-03 09:23 |
> Does anyone else have an opinion one way or another? I'm neutral. |
|
|
msg164753 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2012-07-06 20:11 |
I agree with Raymond. You might, however, emphasize 'normal' in 'normal interpreter termination'. That is the key point. The 'note' merely explains 'abnormal'. |
|
|
msg165482 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-15 01:16 |
Okay, I'll remove the ".. note". Checking in shortly. |
|
|
msg165483 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-07-15 01:21 |
New changeset f8b520b6f654 by Larry Hastings in branch 'default': - Issue #15233: Python now guarantees that callables registered with http://hg.python.org/cpython/rev/f8b520b6f654 |
|
|
msg165484 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-15 01:22 |
So, it's checked in to trunk. Shall I also backport to 2.7 and 3.2 as the issue suggests? |
|
|
msg165535 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-07-15 16:55 |
> Shall I also backport to 2.7 and 3.2 as the issue suggests? If the tests are there, yes! |
|
|
msg165567 - (view) |
Author: Larry Hastings (larry) *  |
Date: 2012-07-16 04:56 |
I have been meditating on this, and I'm not sure we should change 2.7. 3.2 might be okay. The thing is, I fear we're not just talking about CPython implementation details, we're talking about the Python Standard Library. The existing documentation clearly gives alternative implementations free license to call atexit registered functions in any order they like. So it's conceivable that other implementations don't guarantee reverse order. I don't know what the right thing is to do here. It seems like we could define atexit's behavior for 2.7 *if* all the major alternative implementations happily also implicitly guarantee reverse order. Failing that we probably shouldn't touch it. Or we could just document that reverse order is guaranteed in CPython only. Of course, there are no alternative implementations that support 3.2. That's why I think 3.2 might be okay. It does seem strange to redefine part of the implicit language spec more than a year after the release shipped though. |
|
|
msg165576 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2012-07-16 07:01 |
+1 for backport. There's no benefit to leaving ambiguity floating about, nor was there ever any intention for the behavior to have been different. |
|
|
msg172599 - (view) |
Author: Charles-François Natali (neologix) *  |
Date: 2012-10-10 19:31 |
Ping. Like Raymond, I think there's no reason to leave ambiguity in 2.7 and 3.2, so this doc patch is probably worth backporting. |
|
|
msg194258 - (view) |
Author: Charles-François Natali (neologix) *  |
Date: 2013-08-03 13:31 |
Unless anyone objects, I'll backport it soonish. |
|
|
msg195803 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-08-21 16:27 |
New changeset 84d74eb7a341 by Charles-François Natali in branch '2.7': Issue #15233: Python now guarantees that callables registered with the atexit http://hg.python.org/cpython/rev/84d74eb7a341 |
|
|
msg195805 - (view) |
Author: Charles-François Natali (neologix) *  |
Date: 2013-08-21 16:47 |
Backported to 2.7. |
|
|