Skip to content
Snippets Groups Projects
Commit 11a38d5d authored by roland's avatar roland Committed by Damien George
Browse files

tools/pydfu.py: Make the DFU tool work again with Python 2.

This patch will work for both Python 2 and 3.
parent 434975de
Branches
No related tags found
No related merge requests found
...@@ -61,8 +61,12 @@ __verbose = None ...@@ -61,8 +61,12 @@ __verbose = None
# USB DFU interface # USB DFU interface
__DFU_INTERFACE = 0 __DFU_INTERFACE = 0
# Python 3 deprecated getargspec in favour of getfullargspec, but
# Python 2 doesn't have the latter, so detect which one to use
import inspect import inspect
if 'length' in inspect.getfullargspec(usb.util.get_string).args: getargspec = getattr(inspect, 'getfullargspec', inspect.getargspec)
if 'length' in getargspec(usb.util.get_string).args:
# PyUSB 1.0.0.b1 has the length argument # PyUSB 1.0.0.b1 has the length argument
def get_string(dev, index): def get_string(dev, index):
return usb.util.get_string(dev, 255, index) return usb.util.get_string(dev, 255, index)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment