Reviewed: https://review.opendev.org/c/openstack/nova/+/952966 Committed: https://opendev.org/openstack/nova/commit/7d946c45350be935a964990e60bd5213c9aa1423 Submitter: "Zuul (22348)" Branch: master
commit 7d946c45350be935a964990e60bd5213c9aa1423 Author: Balazs Gibizer <[email protected]> Date: Wed Jun 25 10:30:09 2025 +0200 Fix neutron client dict grabbing Due to a bug in python3.13 [1] the following code will leads to an emptied dict by the GC even though we hold a reference to the dict. import gc class A: def __init__(self, client): self.__dict__ = client.__dict__ self.client = client class B: def __init__(self): self.test_attr = "foo" a = A(B()) print(a.__dict__) print(a.client.__dict__) gc.collect() print("## After gc.collect()") print(a.__dict__) print(a.client.__dict__) # Output with Python 13 {'test_attr': 'foo', 'client': <__main__.B object at 0x73ea355a8590>} {'test_attr': 'foo', 'client': <__main__.B object at 0x73ea355a8590>} ## After gc.collect() {'test_attr': 'foo', 'client': <__main__.B object at 0x73ea355a8590>} {} # Output with Python 12 {'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>} {'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>} ## After gc.collect() {'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>} {'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400> Our neutron client has this kind of code and therefore failing in python3.13. This patch adds __getattr__ instead of trying to hold a direct reference to the __dict__. This seems to work around the problem. Co-Authored-By: Johannes Kulik <[email protected]> [1] https://github.com/python/cpython/issues/130327 Closes-Bug: #2103413 Change-Id: I87c9fbb9331135674232c6e77d700966a938b0ac ** Changed in: nova Status: In Progress => Fix Released -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2103413 Title: Python3.13: Garbage collection happens too early on greenthread switches To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/2103413/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
