Skip to content

Python dictionary watchers no longer trigger when an object's attributes change #125608

Description

@colesbury

Bug report

Here's an example function using test_capi/test_watchers.py that passes in 3.12, but fails in 3.13 and 3.14:

    def test_watch_obj_dict(self):
        o = MyClass()
        with self.watcher() as wid:
            self.watch(wid, o.__dict__)
            o.foo = "bar"
            self.assert_events(["new:foo:bar"])  # fails in 3.13+ 

The dictionary watcher doesn't fire in 3.13+ even though the o.__dict__ changes when o.foo is set to "bar". The problem is specific to inline values -- our code paths for inline values do not trigger dictionary watcher events. If the object does not use inline values, then the watcher events fire as expected.

This is a problem for PyTorch Dyanmo because it uses dictionary watchers for compiler guards.

cc @williamwen42 @markshannon

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.13only security fixes
    3.14bugs and security fixes
    on Oct 16, 2024
  2. williamwen42 commented on Oct 16, 2024

    @williamwen42
    Contributor
  3. added 3 commits that reference this issue on Oct 16, 2024
  4. added a commit that references this issue on Oct 25, 2024
  5. added a commit that references this issue on Oct 25, 2024
  6. added a commit that references this issue on Jan 12, 2025
  7. ZeroIntensity commented on Jan 28, 2025

    @ZeroIntensity
    Member

    Doing some triaging, this looks like it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixes3.14bugs and security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions