Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading documentation about weakrefs #59138

Closed
pitrou opened this issue May 28, 2012 · 2 comments
Closed

Misleading documentation about weakrefs #59138

pitrou opened this issue May 28, 2012 · 2 comments
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented May 28, 2012

BPO 14933
Nosy @tim-one, @freddrake, @ncoghlan, @pitrou

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 = None
closed_at = <Date 2012-06-15.17:16:14.039>
created_at = <Date 2012-05-28.13:17:39.225>
labels = ['type-bug', 'docs']
title = 'Misleading documentation about weakrefs'
updated_at = <Date 2012-06-15.17:16:14.038>
user = 'https://github.com/pitrou'

bugs.python.org fields:

activity = <Date 2012-06-15.17:16:14.038>
actor = 'pitrou'
assignee = 'docs@python'
closed = True
closed_date = <Date 2012-06-15.17:16:14.039>
closer = 'pitrou'
components = ['Documentation']
creation = <Date 2012-05-28.13:17:39.225>
creator = 'pitrou'
dependencies = []
files = []
hgrepos = []
issue_num = 14933
keywords = []
message_count = 2.0
messages = ['161780', '162922']
nosy_count = 7.0
nosy_names = ['tim.peters', 'fdrake', 'ncoghlan', 'pitrou', 'docs@python', 'python-dev', 'sbt']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue14933'
versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

@pitrou
Copy link
Member Author

pitrou commented May 28, 2012

In http://docs.python.org/dev/extending/newtypes.html?highlight=pyobject_clearweakrefs#weak-reference-support, you can read:

“The only further addition is that the destructor needs to call the weak reference manager to clear any weak references. This should be done before any other parts of the destruction have occurred”

I don't believe there is any need to clear weakrefs before starting with other parts of the destruction. Weakref callbacks cannot access the original object, by construction (else they never get called).

Actually, if a weakref callback can rely on some resources having been released (say, a file descriptor), it is better to clear the weakrefs *after* other parts of the destruction.

This seems to be a by-product of the erroneous doc committed in SVN r16381, part of which was removed in r18223.

@pitrou pitrou added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels May 28, 2012
@python-dev
Copy link
Mannequin

python-dev mannequin commented Jun 15, 2012

New changeset 69177ff1a643 by Antoine Pitrou in branch '3.2':
Issue bpo-14933: fix misleading doc about weakref support in extension types.
http://hg.python.org/cpython/rev/69177ff1a643

New changeset b17c8005e08a by Antoine Pitrou in branch 'default':
Issue bpo-14933: fix misleading doc about weakref support in extension types.
http://hg.python.org/cpython/rev/b17c8005e08a

New changeset 0ac1f90954dc by Antoine Pitrou in branch '2.7':
Issue bpo-14933: fix misleading doc about weakref support in extension types.
http://hg.python.org/cpython/rev/0ac1f90954dc

@pitrou pitrou closed this as completed Jun 15, 2012
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant