fabioz / PyDev.Debugger

Sources for the debugger used in PyDev, PyCharm and VSCode Python
Eclipse Public License 1.0
425 stars 123 forks source link

TypeError: Error when calling the metaclass bases #147

Open EricSalemi opened 5 years ago

EricSalemi commented 5 years ago

The pydevd_thread_wrappers.py module decorates the Queue class. Somewhere in my code I define the dataBuffer class that derives from the Queue class but when I try to run my script in PyCharm "concurrency diagram" mode Python fails with a weird error:

Importing test library 'RXLibrary' failed: TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str
Traceback (most recent call last):
  File "C:\Users\salemi\Documents\vcs\spark\libraries\RXLibrary.py", line 32, in <module>
    import septentrio.pytest_rxGeneric as rxGeneric
  File "C:\Users\salemi\Documents\vcs\spark\libraries\septentrio\pytest_rxGeneric.py", line 8, in <module>
    import pytest_dataInOut as dataInOut
  File "C:\Users\salemi\Documents\vcs\spark\libraries\septentrio\pytest_dataInOut.py", line 67, in <module>
    class dataBuffer(Queue.Queue):
PYTHONPATH:
  C:\Users\salemi\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\191.7479.30\helpers\pydev
...

As far as I know a decorated class becomes a function and I could understand that Python cannot derive from a function.

How can I solve this problem?

fabioz commented 5 years ago

It seems that the PyCharm version has things not available in the version on pydevd (there's no pydevd_thread_wrappers.py module in pydevd), so, you should report to PyCharm.

EricSalemi commented 5 years ago

The module is there:

https://github.com/fabioz/PyDev.Debugger/blob/master/pydevd_concurrency_analyser/pydevd_thread_wrappers.py

fabioz commented 5 years ago

Oops, sorry about that... I think I searched for something wrong -- reopening ;)

EricSalemi commented 5 years ago

No problem :)

Would it help to create a small reproducible example?

fabioz commented 5 years ago

If you're up to it, what would really help is a test-case (see: tests_python/test_debugger.py) -- as a note, the concurrency analyzer is currently lacking tests, but it should be straightforward to create a test for it based on other tests.

EricSalemi commented 5 years ago

I will take a shot at creating a failing test case.