[New-bugs-announce] [issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

kam193 report at bugs.python.org
Tue Jul 14 10:57:16 EDT 2020


New submission from kam193 <kam193 at wp.pl>:

CPython 3.8.4 broke previously correct custom __setattr__ implementation, when metaclass inheritances from multiple classes, including not-meta.

Following code:

```
class Meta(type):
    def __setattr__(cls, key, value):
        type.__setattr__(cls, key, value)

class OtherClass:
    pass


class DefaultMeta(OtherClass, Meta):
    pass

obj = DefaultMeta('A', (object,), {})
obj.test = True
print(obj.test)
```

Works in Python up to 3.8.3, but in 3.8.4 it raises:

Traceback (most recent call last):
  File "repr.py", line 13, in <module>
    obj.test = True
  File "repr.py", line 3, in __setattr__
    type.__setattr__(cls, key, value)
TypeError: can't apply this __setattr__ to DefaultMeta object

This change affects e.g. https://github.com/pallets/flask-sqlalchemy/issues/852

----------
messages: 373637
nosy: kam193
priority: normal
severity: normal
status: open
title: CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41295>
_______________________________________


More information about the New-bugs-announce mailing list