From 37539a15558ec4b486ee78faaad525565170a698 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 8 Oct 2024 13:36:20 +0100 Subject: [PATCH] bitbake: COW: Fix hardcoded magic numbers and work with python 3.13 The COW tests started failing on python 3.13. Looks like it is time to fix the FIXME and drop the magic numbers! (Bitbake rev: a0a5ce49f28d886b1dac173842642e69517b44e3) Signed-off-by: Richard Purdie (cherry picked from commit 2e6608cec508b3b9bab3530f83e70665ff638182) [YC: This fixes the bb.tests.cow.COWTestCase.testOriginalTestSuite bitbake-selftest on the newly added fedora-41 workers] Signed-off-by: Yoann Congal Signed-off-by: Paul Barker Signed-off-by: Richard Purdie --- bitbake/lib/bb/COW.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bitbake/lib/bb/COW.py b/bitbake/lib/bb/COW.py index 76bc08a3ea..4af03c54ad 100644 --- a/bitbake/lib/bb/COW.py +++ b/bitbake/lib/bb/COW.py @@ -36,8 +36,9 @@ class COWDictMeta(COWMeta): __marker__ = tuple() def __str__(cls): - # FIXME: I have magic numbers! - return "" % (cls.__count__, len(cls.__dict__) - 3) + ignored_keys = set(["__count__", "__doc__", "__module__", "__firstlineno__", "__static_attributes__"]) + keys = set(cls.__dict__.keys()) - ignored_keys + return "" % (cls.__count__, len(keys)) __repr__ = __str__ @@ -161,8 +162,9 @@ class COWDictMeta(COWMeta): class COWSetMeta(COWDictMeta): def __str__(cls): - # FIXME: I have magic numbers! - return "" % (cls.__count__, len(cls.__dict__) - 3) + ignored_keys = set(["__count__", "__doc__", "__module__", "__firstlineno__", "__static_attributes__"]) + keys = set(cls.__dict__.keys()) - ignored_keys + return "" % (cls.__count__, len(keys)) __repr__ = __str__