Steven D'Aprano added the comment: I had a brief look at the source for ABCMeta, and it seems to me that the __module__ behaviour is coming from `type`. I'm not sure whether it can, or should, can be fixed in type, but I think that the correct behaviour for ABCMeta is to set __module__ to the caller's global "__name__", not its own.
Something like this should probably work: class ABCMeta(type): def __new__(mcls, name, bases, namespace): if '__module__' not in namespace: # globals()['__name__'] gives 'abc' frame = inspect.currentframe() if frame is not None: # IronPython? caller_globals = frame.f_back.f_globals namespace['__module__'] = caller_globals['__name__'] cls = super().__new__(mcls, name, bases, namespace) ... ---------- nosy: +steven.daprano _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28869> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com