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
weakref.ref ignores a 'callback' keyword argument #61965
Comments
Passing a weakref.ref callback by keyword currently fails silently: Python 3.4.0a0 (default:537c1f1ab53c, Apr 16 2013, 20:07:47)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import weakref
>>> weakref.ref({1, 2, 3}, callback=lambda ref:print("collected"))
<weakref at 0x1006189d8; dead> For Python 3.4, I'd suggest that either (1) this should be an exception, or (2) it should be permissible to pass the callback by keyword. |
See attached patch, it handles this like all other builtins that don't support keyword arguments in their constructor. |
Why the PyWeakref_Check() in your patch? |
Good point, that is pointless in __init__(). |
no_weakref_kwargs_2.patch LGTM. |
Serhiy, feel free to go ahead and commit, I don't have my keys with me ATM. |
New changeset ee17a83feabc by Serhiy Storchaka in branch '3.5': New changeset 60de9c6188cc by Serhiy Storchaka in branch '2.7': New changeset ef55fa8c4b82 by Serhiy Storchaka in branch 'default': |
Done. This issue is similar to recently closed bpo-26822. Please give me know if you have other ready to review patches. |
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: