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 steven.daprano
Recipients abarry, levkivskyi, steven.daprano
Date 2016-12-04.23:15:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)
Date User Action Args
2016-12-04 23:15:31steven.dapranosetrecipients: + steven.daprano, levkivskyi, abarry
2016-12-04 23:15:31steven.dapranosetmessageid: <>
2016-12-04 23:15:31steven.dapranolinkissue28869 messages
2016-12-04 23:15:31steven.dapranocreate