Skip to content

Commit 6dd4467

Browse files
committed
libusb1: Fix get_extra on python 2.7 .
Whereas single-item retrieval on a "bytes" instance yields a string and hence requires an "ord" call, on "bytearray" instance it yields an integer directly. This was broken by: commit b26f6cd Author: Vincent Pelletier <plr.vincent@gmail.com> Date: Sun Oct 16 11:14:04 2016 +0000 Use writeable buffer for transfers (sync & async). along with buffer_at cast to bytearray.
1 parent 78b0688 commit 6dd4467

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

usb1/libusb1.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ def __str__(self):
140140
return '%s [%s]' % (libusb_error.get(self.value, 'Unknown error'),
141141
self.value)
142142

143-
if sys.version_info[0] == 3:
144-
_string_item_to_int = lambda x: x
145-
else:
146-
_string_item_to_int = ord
147-
148143
c_uchar = c_uint8
149144
c_int_p = POINTER(c_int)
150145

@@ -1104,7 +1099,7 @@ def get_extra(descriptor):
11041099
extra = buffer_at(descriptor.extra, extra_length)
11051100
append = result.append
11061101
while extra:
1107-
length = _string_item_to_int(extra[0])
1102+
length = extra[0]
11081103
if not 0 < length <= len(extra):
11091104
raise ValueError(
11101105
'Extra descriptor %i is incomplete/invalid' % (

0 commit comments

Comments
 (0)