rene-aguirre / pywinusb

USB / HID windows helper library
BSD 3-Clause "New" or "Revised" License
207 stars 63 forks source link

core.py collections callable error #81

Open ThommyL34 opened 1 year ago

ThommyL34 commented 1 year ago

Hi,

I tried the example show_hids.py from this repo and this error occurs:

..Project\venv\Lib\site-packages\pywinusb\hid\core.py", line 1567, in inspect if isinstance(value, collections.Callable): ^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'collections' has no attribute 'Callable'

Specs:

Note: Googl`d error background: This error occurs in other contexts, too. Mostly when older packages are being used in combination with modern python versions. So I think i found a fix and I thought about sharing it if you want to include it in a future version.

The Fix:

File: core.py Action: 1) Replace line 14 from import collections to import _collections_abc 2) Replace line 1567 from if isinstance(value, collection.Callable): to if isinstance(value, _collections_abc.Callable).

New behavior:

No error message and a long print of HID information.