kislyuk / eight

Python 2 to the power of 3
https://eight.readthedocs.org/
Apache License 2.0
47 stars 6 forks source link

Support eight.__name__ and raise correct AttributeError #4

Closed mbarrien closed 8 years ago

mbarrien commented 8 years ago

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.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+1.06%) to 82.979% when pulling bde63e8b3f3ae7ab5010ee1f5d94927dfed86381 on mbarrien:master into fc243e0602218829b2dd9d8c026a683924095a38 on kislyuk:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+1.06%) to 82.979% when pulling bde63e8b3f3ae7ab5010ee1f5d94927dfed86381 on mbarrien:master into fc243e0602218829b2dd9d8c026a683924095a38 on kislyuk:master.

kislyuk commented 8 years ago

LGTM, thank you!