vpelletier / python-libusb1

Python ctype-based wrapper around libusb1
GNU Lesser General Public License v2.1
168 stars 65 forks source link

unorderable types in USBTransfer.cancel #20

Closed kalvdans closed 7 years ago

kalvdans commented 7 years ago

I got an error when calling cancel on a transfer. Test code:

import usb1

def on_read_finished(transfer):
    pass

context = usb1.USBContext()
handle = context.openByVendorIDAndProductID(
    0x10c4, 0x842a, skip_on_error=True,
)
transfer = handle.getTransfer()
transfer.setBulk(0x81, 65536, callback=lambda:0)
transfer.submit()
transfer.cancel()

Error:

Traceback (most recent call last):
  File "scripts/repro.py", line 13, in 
    transfer.cancel()
  File "/usr/local/lib/python3.5/dist-packages/usb1.py", line 748, in cancel
    self.__mayRaiseUSBError(self.__libusb_cancel_transfer(self.__transfer))
  File "/usr/local/lib/python3.5/dist-packages/usb1.py", line 132, in mayRaiseUSBError
    if value < 0:
TypeError: unorderable types: USBTransfer() < int()

Python 3.5.2, libusb1 (1.5.2) installed via pip, libusb-1.0-0:amd64 version 2:1.0.20-1 installed via apt.``

vpelletier commented 7 years ago

Very nice bug, thanks for the report. This should be fixed as of 2132f56e7e0dfc8592bfa93d0ce54ec4f3ee0018.

I'll release when travis gives me the green light.

vpelletier commented 7 years ago

Done, 1.5.3 released on pypi.