New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing bug with jsonrpc._Method caused by debugger #24
Conversation
Adding __repr__, __str__ and __dir__ to jsonrpc._Method in order to avoid issues with PyCharm debugger due to these functions being called and accessing __getattr__ which mutates the _Method object
@joshmarshall I noticed you're active in the last few days so wanted to necro this and get your thoughts on this issue. Is it not worth fixing? |
Hi @efokschaner - I think it is worth fixing. It looks like this is still the first implementation -- did you want to open a PR with the immutable _Method() approach? |
@joshmarshall Thanks for the reply, I'll prepare the PR with the recommended fix. |
@joshmarshall I've updated the PR with the |
@joshmarshall How does this look? |
@efokschaner Thoughts? |
@joshmarshall |
@efokschaner Alright -- 0.1.4 is released on PyPI and in Travis. Let's make this 0.1.5. :) |
@joshmarshall Test is added, let me know how it looks. |
@efokschaner Hey -- the test looks good. Sorry, I had a pip install issue with the setup.py + the automated Travis push to PyPI last week, so I had to deal with that. Will merge this fix in as 0.1.7 hopefully this weekend if that works for you. |
@joshmarshall fine by me! |
@joshmarshall You might prefer to merge #43 first. |
@joshmarshall Don't forget this one :) |
@joshmarshall any eta on this merge? |
@joshmarshall Just gonna bump this PR, let me know if you're too busy to deal with the merge. |
Fixing bug with jsonrpc._Method caused by debugger
Only took me two years, but it's closed now. Thanks so much for your work and patience! |
@joshmarshall Outstanding, you should see my face right now :D |
Whilst debugging jsonrpclib with PyCharm I observed odd behaviour with jsonrpc._Method due to pycharm using the repr, str and dir methods in order to populate its debug information. These calls would be handled by getattr which would modify the object, corrupting the method name chain. xmlrpclib does not have this issue because it does not make the same optimisation of mutating the existing object but returns a new object when getattr is called (this might actually be a preferable approach to what i am proposing, so consider it as another option).
UPDATE:
After working with the library a bit more i think it would be preferable to revert back to the xmlrpclib approach of not mutating _Method and returning a a new instance each time getattr is called. Because it allows code such as this to work:
If we mutate the _Method then the 'qux()' call would not behave as expected.
Let me know if there are any questions or concerns.