summaryrefslogtreecommitdiff
path: root/tools/pydfu.py
diff options
context:
space:
mode:
authorroland <roland@van-straten.org>2018-07-27 07:55:32 +0200
committerDamien George <damien.p.george@gmail.com>2018-07-27 16:53:50 +1000
commit11a38d5dc5365c9fa1d3edc05f948e21293ce127 (patch)
tree4fbdb81a997230ca742e866c5b2765c41b2c8e19 /tools/pydfu.py
parent434975defac12125e550d42eb71d5454e0386d51 (diff)
tools/pydfu.py: Make the DFU tool work again with Python 2.
This patch will work for both Python 2 and 3.
Diffstat (limited to 'tools/pydfu.py')
-rwxr-xr-xtools/pydfu.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/pydfu.py b/tools/pydfu.py
index 112e354ec..c6b6802c8 100755
--- a/tools/pydfu.py
+++ b/tools/pydfu.py
@@ -61,8 +61,12 @@ __verbose = None
# USB DFU interface
__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
-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
def get_string(dev, index):
return usb.util.get_string(dev, 255, index)