PyDev.Debugger
PyDev.Debugger copied to clipboard
AttributeError: _mock_methods
Whenever I start PyCharm's debugger, I'm getting an error logged on this line: https://github.com/fabioz/PyDev.Debugger/blob/81197dcd8ae59c29ddf12cd20a084dc3b4dcf750/_pydevd_bundle/pydevd_utils.py#L135
Traceback (most recent call last):
File "/Users/me/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-1/192.4205.50/PyCharm 2019.2 EAP.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_signature.py", line 97, in create_signature
_, modulename, funcname = self.file_module_function_of(frame)
File "/Users/me/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-1/192.4205.50/PyCharm 2019.2 EAP.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_signature.py", line 122, in file_module_function_of
clsname = get_clsname_for_code(code, frame)
File "/Users/me/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-1/192.4205.50/PyCharm 2019.2 EAP.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_utils.py", line 112, in get_clsname_for_code
first_arg_class = first_arg_obj.__class__
File ".../venv/lib/python2.7/site-packages/mock/mock.py", line 696, in __getattr__
elif self._mock_methods is not None:
File ".../venv/lib/python2.7/site-packages/mock/mock.py", line 695, in __getattr__
raise AttributeError(name)
AttributeError: _mock_methods
It looks like the mock package somehow interferes here, since it overrides the __class__ attribute. Everything seems to be working as usual, but it adds a lot of noise to the output. I'm basically changing this line
first_arg_class = first_arg_obj.__class__
to
first_arg_class = type(first_arg_obj)
whenever I upgrade PyCharm, which makes the log message go away.
I do not fully understand the implications of that though. Does that seem like a safe change? Happy to open a PR with that change!