From becb905f043c2b8a85b6ef099e82220988eae3fd 2022-08-17 08:33:36 From: Hugues Hoppe Date: 2022-08-17 08:33:36 Subject: [PATCH] Let %autoreload work on modules with frozen dataclasses See Issue #12411 and Issue #12185. The problem is that a frozen `dataclasses.dataclass` overrides the `__setattr__()` method, so updating its `__class__` member requires going through the base `object` class. This seems to fix the problem. --- diff --git a/IPython/extensions/autoreload.py b/IPython/extensions/autoreload.py index 816d2f3..a0a8c27 100644 --- a/IPython/extensions/autoreload.py +++ b/IPython/extensions/autoreload.py @@ -300,7 +300,7 @@ def update_instances(old, new): for ref in refs: if type(ref) is old: - ref.__class__ = new + object.__setattr__(ref, "__class__", new) def update_class(old, new):