[issue24183] ABCMeta classes do not support the **kwargs standard class interface

Timothy Cardenas report at bugs.python.org
Thu May 14 02:34:22 CEST 2015


Timothy Cardenas added the comment:

Hmm Ok. You are right i can do the following:

from collections import UserDict
from abc import ABCMeta


class MetaMyDict(ABCMeta):

    @classmethod
    def __prepare__(cls, name, bases, **kwargs):
        return {}

    def __new__(mcls, name, bases, namespace, **kwds):
        return super().__new__(mcls, name, bases, namespace)

    def __init__(cls, name, bases, namespace, **kargs):
        return super().__init__(name, bases, namespace)

class MyDict(UserDict, metaclass=MetaMyDict, bar='baz'):
    pass

dictionary = MyDict()

But I guess i would have expected a core lib library to be consistent with the data model https://docs.python.org/3.4/reference/datamodel.html#preparing-the-class-namespace. As it stands an end user can't get a subclass of ABCMeta to work with the same **kwargs interface without creating a custom metaclass that strips it out before passing to ABCMeta. 

Wouldn't it be much easier and technically correct for the core ABCMeta library to adopt the same interface contract for class creation introduced in python3?

----------
resolution: not a bug -> remind
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24183>
_______________________________________


More information about the Python-bugs-list mailing list