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

weakref.ref ignores a 'callback' keyword argument #61965

Closed
mdickinson opened this issue Apr 16, 2013 · 8 comments
Closed

weakref.ref ignores a 'callback' keyword argument #61965

mdickinson opened this issue Apr 16, 2013 · 8 comments
Assignees
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@mdickinson
Copy link
Member

BPO 17765
Nosy @birkenfeld, @mdickinson, @pitrou, @serhiy-storchaka
Files
  • no_weakref_kwargs.patch
  • no_weakref_kwargs_2.patch
  • 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 = 'https://github.com/birkenfeld'
    closed_at = <Date 2016-05-07.12:48:00.102>
    created_at = <Date 2013-04-16.19:11:10.329>
    labels = ['extension-modules', 'type-bug']
    title = "weakref.ref ignores a 'callback' keyword argument"
    updated_at = <Date 2016-05-07.12:48:00.101>
    user = 'https://github.com/mdickinson'

    bugs.python.org fields:

    activity = <Date 2016-05-07.12:48:00.101>
    actor = 'serhiy.storchaka'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2016-05-07.12:48:00.102>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2013-04-16.19:11:10.329>
    creator = 'mark.dickinson'
    dependencies = []
    files = ['32118', '32119']
    hgrepos = []
    issue_num = 17765
    keywords = ['patch']
    message_count = 8.0
    messages = ['187115', '199898', '199904', '199909', '264954', '265056', '265062', '265063']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'mark.dickinson', 'pitrou', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue17765'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @mdickinson
    Copy link
    Member Author

    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.

    @mdickinson mdickinson added the type-feature A feature request or enhancement label Apr 16, 2013
    @birkenfeld
    Copy link
    Member

    See attached patch, it handles this like all other builtins that don't support keyword arguments in their constructor.

    @pitrou
    Copy link
    Member

    pitrou commented Oct 14, 2013

    Why the PyWeakref_Check() in your patch?

    @birkenfeld
    Copy link
    Member

    Good point, that is pointless in __init__().

    @serhiy-storchaka
    Copy link
    Member

    no_weakref_kwargs_2.patch LGTM.

    @serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels May 6, 2016
    @birkenfeld
    Copy link
    Member

    Serhiy, feel free to go ahead and commit, I don't have my keys with me ATM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 7, 2016

    New changeset ee17a83feabc by Serhiy Storchaka in branch '3.5':
    Issue bpo-17765: weakref.ref() no longer silently ignores keyword arguments.
    https://hg.python.org/cpython/rev/ee17a83feabc

    New changeset 60de9c6188cc by Serhiy Storchaka in branch '2.7':
    Issue bpo-17765: weakref.ref() no longer silently ignores keyword arguments.
    https://hg.python.org/cpython/rev/60de9c6188cc

    New changeset ef55fa8c4b82 by Serhiy Storchaka in branch 'default':
    Issue bpo-17765: weakref.ref() no longer silently ignores keyword arguments.
    https://hg.python.org/cpython/rev/ef55fa8c4b82

    @serhiy-storchaka
    Copy link
    Member

    Done. This issue is similar to recently closed bpo-26822.

    Please give me know if you have other ready to review patches.

    @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
    extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants