Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CallbackRegistry should not silently drop duplicate callbacks #20210

Open
@anntzer

Description

@anntzer

Bug report

Bug summary

Currently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per

proxy=_weak_or_strong_ref(func,self._remove_proxy)
ifproxyinself._func_cid_map[signal]:
returnself._func_cid_map[signal][proxy]

This seems not so nice and a bit surprising (as in#15785 (comment)); we should deprecate that behavior and either

  • (preferred) just always perform the connection, even if duplicated; it's the user's job to keep track of duplicates if they want; or
  • (less preferred) add something likekeep_duplicates={None,True,False} where None (default) raises an exception for duplicates, True keeps them, False drops them.

Code for reproduction

for_inrange(2):gcf().canvas.mpl_connect("button_press_event",print)show()

and click on the canvas.

Actual outcome

The event is printed once.

Expected outcome

The event is printed twice.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): HEAD (3.4.x+)
  • Matplotlib backend (print(matplotlib.get_backend())): any
  • Python version: 39
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp