This issue was initially reported in Stewori/pytypes#18.
Applying __module__ on e.g. the __init__ function generated by attrs raises a KeyError. For more information please refer to the link above.
Being able to retrieve the module for a given function/method is relevant to locate the function or method in the class hierarchy from perspective of a decorator or profiler. Searching a module top-down for a function/method is often the only way to access its enclosing class, including nesting structure of classes.
A workaround that sometimes worked but not in this case is to get the module via __code__.co_filename. However, any valid approach for identifying the corresponding module and/or location in class hierarchy for a generated function would be fine.
Please apologize if I should overlook some approach that is already viable.
This issue was initially reported in Stewori/pytypes#18.
Applying
__module__on e.g. the__init__function generated by attrs raises aKeyError. For more information please refer to the link above.Being able to retrieve the module for a given function/method is relevant to locate the function or method in the class hierarchy from perspective of a decorator or profiler. Searching a module top-down for a function/method is often the only way to access its enclosing class, including nesting structure of classes.
A workaround that sometimes worked but not in this case is to get the module via
__code__.co_filename. However, any valid approach for identifying the corresponding module and/or location in class hierarchy for a generated function would be fine.Please apologize if I should overlook some approach that is already viable.