diff --git a/tools/pydfu.py b/tools/pydfu.py
index 112e354ecf9cd6aab9f86a162fbc21ac12ba017e..c6b6802c836fb01492d18fa9673986b9acb39e9a 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)