Skip to content

Commit f3fed98

Browse files
committed
pybricksdev._vendored.dfu_upload: fix Python 3.11 compatibility
Python 3.11 dropped inspect.getargspec so we are no getting an AttributeError. This was for Python 2 compatibility, so we can just removed it and use getfullargspec() exclusively. Fixes: pybricks/support#973
1 parent 5b608c5 commit f3fed98

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Fixed Python 3.11 compatibility of vendored `dfu_upload` module ([support#973]).
11+
12+
[support#973]: https://github.com/pybricks/support/issues/973
13+
914
## [1.0.0-alpha.38] - 2023-03-03
1015

1116
### Added

pybricksdev/_vendored/dfu_upload.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@
8383
# USB DFU interface
8484
__DFU_INTERFACE = 0
8585

86-
# Python 3 deprecated getargspec in favour of getfullargspec, but
87-
# Python 2 doesn't have the latter, so detect which one to use
88-
getargspec = getattr(inspect, "getfullargspec", inspect.getargspec)
89-
90-
if "length" in getargspec(usb.util.get_string).args:
86+
if "length" in inspect.getfullargspec(usb.util.get_string).args:
9187
# PyUSB 1.0.0.b1 has the length argument
9288
def get_string(dev, index):
9389
return usb.util.get_string(dev, 255, index)

0 commit comments

Comments
 (0)