Eight interacts badly with libraries that inspect the __name__ attribute of a module. These include things like test libraries that are trying to do dynamic patching like freezegun. Specifically, eight behaves badly when freezegun inspects it at https://github.com/spulec/freezegun/blob/0.3.7/freezegun/api.py#L381 because the loader's __getattribute__() tries to look up eight.__name__ in sys.modules instead of returning the name it already stored.
This PR adds support for __name__, as well as raising the correct AttributeError expected when a non-existent attribute is searched for instead of bubbling up the KeyError. By raising AttributeError, this allows hasattr(eight, 'foo') to work properly.
Coverage increased (+1.06%) to 82.979% when pulling bde63e8b3f3ae7ab5010ee1f5d94927dfed86381 on mbarrien:master into fc243e0602218829b2dd9d8c026a683924095a38 on kislyuk:master.
Coverage increased (+1.06%) to 82.979% when pulling bde63e8b3f3ae7ab5010ee1f5d94927dfed86381 on mbarrien:master into fc243e0602218829b2dd9d8c026a683924095a38 on kislyuk:master.
Eight interacts badly with libraries that inspect the
__name__
attribute of a module. These include things like test libraries that are trying to do dynamic patching like freezegun. Specifically, eight behaves badly when freezegun inspects it at https://github.com/spulec/freezegun/blob/0.3.7/freezegun/api.py#L381 because the loader's__getattribute__()
tries to look upeight.__name__
insys.modules
instead of returning the name it already stored.This PR adds support for
__name__
, as well as raising the correct AttributeError expected when a non-existent attribute is searched for instead of bubbling up the KeyError. By raising AttributeError, this allowshasattr(eight, 'foo')
to work properly.