This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients christian.heimes, methane, pitrou, rhettinger, scoder, serhiy.storchaka, vstinner
Date 2017-09-11.16:53:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505148801.98.0.858951465781.issue31336@psf.upfronthosting.co.za>
In-reply-to
Content
Serhiy on the PR: "This is overgeneralization. Can tp_dict be not exact dict at all? I don't think this is possible. In many places concrete dict API is used with tp_dict. If you want to allow tp_dict be not exact dict, please open a separate issue for this."

Using the following code, A.__dict__ type is dict even if the metaclass creates a different type, probably because type_new() calls PyDict_Copy(orig_dict):
---
class mydict(dict):
    def __setitem__(self, name, value):
        if name == "__module__":
            value = "<mock module>"
        super().__setitem__(name, value)

class MetaClass(type):
    @classmethod
    def __prepare__(mcl, name, bases):
        return mydict()

class A(metaclass=MetaClass):
    pass

print(A.__module__)
---
History
Date User Action Args
2017-09-11 16:53:22vstinnersetrecipients: + vstinner, rhettinger, pitrou, scoder, christian.heimes, methane, serhiy.storchaka
2017-09-11 16:53:21vstinnersetmessageid: <1505148801.98.0.858951465781.issue31336@psf.upfronthosting.co.za>
2017-09-11 16:53:21vstinnerlinkissue31336 messages
2017-09-11 16:53:21vstinnercreate