fedora-infra / bodhi

Bodhi is a web-system that facilitates the process of publishing updates for a Fedora-based software distribution.
https://bodhi.fedoraproject.org
GNU General Public License v2.0
150 stars 189 forks source link

Bodhi enums implementation incompatible with Python 3.13 #5685

Closed mattiaverga closed 1 week ago

mattiaverga commented 2 weeks ago

This code, which was taken from an old recipe at http://techspot.zzzeek.org/2011/01/14/the-enum-recipe, doesn't work anymore in Python 3.13:

class EnumSymbol(object):
    def __init__(self, cls_, name, value, description):
        self.cls_ = cls_
        self.name = name
        self.value = value
        self.description = description

class EnumMeta(type):
    def __init__(cls, classname, bases, dict_):
        cls._reg = reg = cls._reg.copy()
        for k, v in dict_.items():
            if isinstance(v, tuple):
                sym = reg[v[0]] = EnumSymbol(cls, k, *v)
                setattr(cls, k, sym)
        return type.__init__(cls, classname, bases, dict_)

class DeclEnum(metaclass=EnumMeta):
    _reg = {}

bodhi-server is currently FTB in F41.