Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-06-29.18:22:49.469>created_at=<Date2019-09-09.08:51:28.823>labels= ['easy', '3.11', '3.9', '3.10', 'docs']
title='Clarify that atexit.unregister matches by equality, not identity'updated_at=<Date2021-06-29.18:22:49.468>user='https://github.com/mdickinson'
and on an instance a = A(), I do: atexit.register(a.cleanup).
Then it's not obvious from the documentation that an atexit.unregister(a.cleanup) will successfully undo the effect of the reigster call: the second a.cleanup is a different object from the first:
>>> a = A()
>>> clean1 = a.cleanup
>>> clean2 = a.cleanup
>>> clean1 is clean2
False
Luckily, though the two bound methods are different objects, they're equal:
>>> clean1 == clean2
True
and from looking at the source, it's apparent that atexit.unregister compares by equality rather than identity, so everything works.
It would be good to add a sentence to the documentation for atexit.unregister to clarify that this can be expected to work.
New changeset 08aa26e by Miss Islington (bot) in branch '3.10': bpo-38062: [doc] clarify that atexit uses equality comparisons internally. (GH-26935) (GH-26956) 08aa26e
New changeset 02859df by Miss Islington (bot) in branch '3.9': bpo-38062: [doc] clarify that atexit uses equality comparisons internally. (GH-26935) (GH-26957) 02859df
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: