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

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

Closed
colesbury opened this issue Oct 16, 2024 · 2 comments
Closed
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@colesbury
Copy link
Contributor

colesbury commented Oct 16, 2024

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

@colesbury colesbury added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Oct 16, 2024
@williamwen42
Copy link
Contributor

cc @anijain2305

colesbury added a commit to colesbury/cpython that referenced this issue Oct 16, 2024
Dictionary watchers on an object's attributes dictionary
(`object.__dict__`) were not triggered when the managed dictionary used
the object's inline values.
colesbury added a commit to colesbury/cpython that referenced this issue Oct 16, 2024
Dictionary watchers on an object's attributes dictionary
(`object.__dict__`) were not triggered when the managed dictionary used
the object's inline values.
colesbury added a commit that referenced this issue Oct 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…5611)

Dictionary watchers on an object's attributes dictionary
(`object.__dict__`) were not triggered when the managed dictionary used
the object's inline values.
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 25, 2024
pythonGH-125611)

Dictionary watchers on an object's attributes dictionary
(`object.__dict__`) were not triggered when the managed dictionary used
the object's inline values.
(cherry picked from commit 5989eb7)

Co-authored-by: Sam Gross <[email protected]>
colesbury added a commit that referenced this issue Oct 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…ge (GH-125611) (GH-125982)

Dictionary watchers on an object's attributes dictionary
(`object.__dict__`) were not triggered when the managed dictionary used
the object's inline values.
(cherry picked from commit 5989eb7)

Co-authored-by: Sam Gross <[email protected]>
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 25, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this issue Oct 25, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this issue Oct 28, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

Pull Request resolved: #138284
Approved by: https://github.com/jansel
ghstack dependencies: #138030
rahulsingh-intel pushed a commit to rahulsingh-intel/pytorch that referenced this issue Oct 29, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

Pull Request resolved: pytorch#138284
Approved by: https://github.com/jansel
ghstack dependencies: pytorch#138030
rahulsingh-intel pushed a commit to rahulsingh-intel/pytorch that referenced this issue Nov 5, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed by python/cpython#125611 but will only be in 3.13.1+.

This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.

Pull Request resolved: pytorch#138284
Approved by: https://github.com/jansel
ghstack dependencies: pytorch#138030
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
python#125611)

Dictionary watchers on an object's attributes dictionary
(`object.__dict__`) were not triggered when the managed dictionary used
the object's inline values.
@ZeroIntensity
Copy link
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
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants