J535D165 / cbsodata

Unofficial Statistics Netherlands (CBS) open data API client for Python
http://cbsodata.readthedocs.io/
MIT License
42 stars 17 forks source link

OptionsManager.__getattr__ use self.__dict__ instead of getattr to avoid recursion #19

Closed nieuwenhoven closed 3 years ago

nieuwenhoven commented 3 years ago

Hi,

I ran into the issue that ipython crashed when importing cbsodata, while running scripts using cbsodata worked just fine. When trying to figure things out using the debugger of PyCharm, the import of cbsodata caused a stackoverflow because of a recursive call of OptionsManager.__getattr__ upon creating the instance of OptionsManager. It appears to be the same problem as issue #16.

The problem was gone after using self.__dict__ to get the attribute instead of calling the getattr builtin.

Kind regards,

Frans

J535D165 commented 3 years ago

Thank you so much @nieuwenhoven, this issue is open for quite a while. Finally, we do have some understanding of what's going on. I don't know why this special method is implemented in this way. It seems like we can remove the entire special method!? Can you give it a try in PyCharm (remove the method)?

nieuwenhoven commented 3 years ago

You are correct. __getattr__ can be removed completely and everything still works!

J535D165 commented 3 years ago

Thanks again @nieuwenhoven. A new release can be found on PyPI.