diff -Nru python-libusb1-1.10.1/debian/changelog python-libusb1-2.0.1/debian/changelog --- python-libusb1-1.10.1/debian/changelog 2022-01-06 12:54:48.000000000 +0000 +++ python-libusb1-2.0.1/debian/changelog 2022-02-04 18:48:31.000000000 +0000 @@ -1,3 +1,17 @@ +python-libusb1 (2.0.1-0.1) unstable; urgency=medium + + * Team upload + + [ Jeremy Bicha ] + * New upstream release + * Cherry-pick patch to fix build with latest libusb-1.0 + + [ Debian Janitor ] + * Add upstream metadata file + * Update standards version to 4.6.0, no changes needed. + + -- Jeremy Bicha Fri, 04 Feb 2022 13:48:31 -0500 + python-libusb1 (1.10.1-0.1) unstable; urgency=medium * Non-maintainer upload. diff -Nru python-libusb1-1.10.1/debian/control python-libusb1-2.0.1/debian/control --- python-libusb1-1.10.1/debian/control 2021-01-25 11:55:02.000000000 +0000 +++ python-libusb1-2.0.1/debian/control 2022-02-04 18:48:31.000000000 +0000 @@ -9,7 +9,7 @@ python3-wheel, libusb-1.0-0 Build-Depends-Indep: python3-setuptools, -Standards-Version: 4.5.0 +Standards-Version: 4.6.0 Homepage: https://github.com/vpelletier/python-libusb1 Vcs-Git: https://salsa.debian.org/python-team/packages/python-libusb1.git Vcs-Browser: https://salsa.debian.org/python-team/packages/python-libusb1 diff -Nru python-libusb1-1.10.1/debian/patches/series python-libusb1-2.0.1/debian/patches/series --- python-libusb1-1.10.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ python-libusb1-2.0.1/debian/patches/series 2022-02-04 18:48:31.000000000 +0000 @@ -0,0 +1 @@ +usb1.testUSB1-Do-not-allocate-libusb-transfers-in-tests.patch diff -Nru python-libusb1-1.10.1/debian/patches/usb1.testUSB1-Do-not-allocate-libusb-transfers-in-tests.patch python-libusb1-2.0.1/debian/patches/usb1.testUSB1-Do-not-allocate-libusb-transfers-in-tests.patch --- python-libusb1-1.10.1/debian/patches/usb1.testUSB1-Do-not-allocate-libusb-transfers-in-tests.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-libusb1-2.0.1/debian/patches/usb1.testUSB1-Do-not-allocate-libusb-transfers-in-tests.patch 2022-02-04 18:48:31.000000000 +0000 @@ -0,0 +1,124 @@ +From: Vincent Pelletier +Date: Thu, 3 Feb 2022 16:14:10 +0000 +Subject: usb1.testUSB1: Do not allocate libusb transfers in tests. + +From 1.0.25, calling libusb_free_transfer without having assigned it to +a device segfaults. This is not a supported call sequence, so hook into +{,de}allocation functions during affected test methods, and use this to +check their consistency. + +(cherry picked from commit 6887f197d216537982ee49a45acd771a6786d75e) +--- + usb1/testUSB1.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 52 insertions(+), 1 deletion(-) + +diff --git a/usb1/testUSB1.py b/usb1/testUSB1.py +index 66d0e0f..b7d8711 100644 +--- a/usb1/testUSB1.py ++++ b/usb1/testUSB1.py +@@ -16,10 +16,13 @@ + + # pylint: disable=invalid-name, missing-docstring, too-many-public-methods + +-from ctypes import pointer ++from ctypes import pointer, sizeof ++import functools ++import gc + import itertools + import sys + import unittest ++import weakref + import usb1 + from . import libusb1 + +@@ -38,7 +41,50 @@ class USBContext(usb1.USBContext): + 'usb1.USBContext() fails - no USB bus on system ?' + ) + ++def checkTransferAllocCount(func): ++ @functools.wraps(func) ++ def wrapper(self, *args, **kw): ++ before = self.transfer_alloc_count ++ libusb_free_transfer = libusb1.libusb_free_transfer ++ libusb_alloc_transfer = libusb1.libusb_alloc_transfer ++ try: ++ libusb1.libusb_free_transfer = self._fakeFreeTransfer ++ libusb1.libusb_alloc_transfer = self._fakeAllocTransfer ++ print('running') ++ result = func(self, *args, **kw) ++ print('done') ++ finally: ++ libusb1.libusb_free_transfer = libusb_free_transfer ++ libusb1.libusb_alloc_transfer = libusb_alloc_transfer ++ gc.collect() ++ self.assertEqual(self.transfer_alloc_count, before) ++ return result ++ return wrapper ++ + class USBTransferTests(unittest.TestCase): ++ def __init__(self, *args, **kw): ++ super().__init__(*args, **kw) ++ usb1.loadLibrary() ++ self.transfer_alloc_count = 0 ++ ++ def _fakeFreeTransfer(self, _): ++ self.transfer_alloc_count -= 1 ++ ++ def _fakeAllocTransfer(self, isochronous_count): ++ self.transfer_alloc_count += 1 ++ buffer = bytearray( ++ sizeof( ++ libusb1.libusb_transfer, ++ ) + sizeof( ++ libusb1.libusb_iso_packet_descriptor, ++ ) * max(0, isochronous_count - 1), ++ ) ++ transfer = libusb1.libusb_transfer.from_buffer(buffer) ++ # Keep a reference (in the finalizer itself) to the buffer for as long ++ # as transfer is alive. ++ weakref.finalize(transfer, lambda _: None, buffer) ++ return pointer(transfer) ++ + @staticmethod + def getTransfer(iso_packets=0): + # Dummy handle +@@ -66,6 +112,7 @@ class USBTransferTests(unittest.TestCase): + """ + usb1.hasCapability(usb1.CAP_HAS_CAPABILITY) + ++ @checkTransferAllocCount + def testSetControl(self): + """ + Simplest test: feed some data, must not raise. +@@ -129,6 +176,7 @@ class USBTransferTests(unittest.TestCase): + # No callback + setter(endpoint, buff) + ++ @checkTransferAllocCount + def testSetBulk(self): + """ + Simplest test: feed some data, must not raise. +@@ -136,6 +184,7 @@ class USBTransferTests(unittest.TestCase): + """ + self._testTransferSetter(self.getTransfer(), 'setBulk') + ++ @checkTransferAllocCount + def testSetInterrupt(self): + """ + Simplest test: feed some data, must not raise. +@@ -143,6 +192,7 @@ class USBTransferTests(unittest.TestCase): + """ + self._testTransferSetter(self.getTransfer(), 'setInterrupt') + ++ @checkTransferAllocCount + def testSetIsochronous(self): + """ + Simplest test: feed some data, must not raise. +@@ -174,6 +224,7 @@ class USBTransferTests(unittest.TestCase): + buff, + ) + ++ @checkTransferAllocCount + def testSetGetCallback(self): + transfer = self.getTransfer() + def callback(transfer): diff -Nru python-libusb1-1.10.1/debian/upstream/metadata python-libusb1-2.0.1/debian/upstream/metadata --- python-libusb1-1.10.1/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ python-libusb1-2.0.1/debian/upstream/metadata 2022-02-04 18:48:31.000000000 +0000 @@ -0,0 +1,5 @@ +--- +Bug-Database: https://github.com/vpelletier/python-libusb1/issues +Bug-Submit: https://github.com/vpelletier/python-libusb1/issues/new +Repository: https://github.com/vpelletier/python-libusb1.git +Repository-Browse: https://github.com/vpelletier/python-libusb1 diff -Nru python-libusb1-1.10.1/examples/hotplug_advanced.py python-libusb1-2.0.1/examples/hotplug_advanced.py --- python-libusb1-1.10.1/examples/hotplug_advanced.py 2020-11-29 07:39:10.000000000 +0000 +++ python-libusb1-2.0.1/examples/hotplug_advanced.py 2021-09-24 22:30:54.000000000 +0000 @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013-2018 Vincent Pelletier +# Copyright (C) 2013-2021 Vincent Pelletier # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,7 +18,7 @@ Advanced hotplug examples. Presents ways of integrating hotplug into your userland USB driver. """ -from __future__ import print_function + import select import sys import usb1 @@ -58,12 +58,12 @@ for fd_list, happened_flag in zip( select.select(*([[ fd - for fd, events in self._fd_dict.iteritems() if events & flag + for fd, events in self._fd_dict.items() if events & flag ] for flag in flag_list] + [timeout])), flag_list, ): result[fd] = result.get(fd, 0) | happened_flag - return result.items() + return list(result.items()) # (end of demonstration helpers) class AwesomeDevice(object): diff -Nru python-libusb1-1.10.1/examples/hotplug.py python-libusb1-2.0.1/examples/hotplug.py --- python-libusb1-1.10.1/examples/hotplug.py 2019-05-09 22:49:51.000000000 +0000 +++ python-libusb1-2.0.1/examples/hotplug.py 2021-09-24 22:30:54.000000000 +0000 @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013-2018 Vincent Pelletier +# Copyright (C) 2013-2021 Vincent Pelletier # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -from __future__ import print_function + import usb1 def hotplug_callback(context, device, event): diff -Nru python-libusb1-1.10.1/examples/listdevs.py python-libusb1-2.0.1/examples/listdevs.py --- python-libusb1-1.10.1/examples/listdevs.py 2019-05-09 22:49:51.000000000 +0000 +++ python-libusb1-2.0.1/examples/listdevs.py 2021-09-24 22:30:54.000000000 +0000 @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013-2018 Vincent Pelletier +# Copyright (C) 2013-2021 Vincent Pelletier # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -from __future__ import print_function + import usb1 def main(): diff -Nru python-libusb1-1.10.1/libusb1.egg-info/PKG-INFO python-libusb1-2.0.1/libusb1.egg-info/PKG-INFO --- python-libusb1-1.10.1/libusb1.egg-info/PKG-INFO 2021-09-22 00:30:43.000000000 +0000 +++ python-libusb1-2.0.1/libusb1.egg-info/PKG-INFO 2021-09-24 22:31:43.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: libusb1 -Version: 1.10.1 +Version: 2.0.1 Summary: Pure-python wrapper for libusb-1.0 Home-page: http://github.com/vpelletier/python-libusb1 Author: Vincent Pelletier @@ -25,7 +25,7 @@ Dependencies ============ - - CPython_ 2.7+ or 3.4+, pypy_ 2.0+. Older versions may work, but are not + - CPython_ 3.4+, pypy_ 2.0+. Older versions may work, but are not recommended as there is no automated regression testing set up for them. - libusb-1.0_ @@ -520,8 +520,13 @@ Add support for homebrew on Apple M1. - 1.10.1 - ------ + 1.10.1 (yanked) + --------------- + + NOTE: Release yanked_ from pypi and re-released as 2.0.0. + + 2.0.0 + ----- Drop python <3.4 support. @@ -534,6 +539,19 @@ Fix objects escaping control from their parent. + 2.0.1 + ----- + + Fix a TypeError exception in USBContext.handleEvents . + + Fix an AttributeError exception in USBContext.hotplugRegisterCallback . + + Fix segfault in pypy3 when finalizing USBDevice objects . + + Source only: convert examples to python3. + + Release process: also run some examples scripts. + .. _CPython: http://www.python.org/ .. _pypy: http://pypy.org/ @@ -552,6 +570,8 @@ .. _Zadig: https://zadig.akeo.ie/ + .. _yanked: https://www.python.org/dev/peps/pep-0592/ + Keywords: usb libusb Platform: any Classifier: Intended Audience :: Developers diff -Nru python-libusb1-1.10.1/PKG-INFO python-libusb1-2.0.1/PKG-INFO --- python-libusb1-1.10.1/PKG-INFO 2021-09-22 00:30:44.032914000 +0000 +++ python-libusb1-2.0.1/PKG-INFO 2021-09-24 22:31:43.440719800 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: libusb1 -Version: 1.10.1 +Version: 2.0.1 Summary: Pure-python wrapper for libusb-1.0 Home-page: http://github.com/vpelletier/python-libusb1 Author: Vincent Pelletier @@ -25,7 +25,7 @@ Dependencies ============ - - CPython_ 2.7+ or 3.4+, pypy_ 2.0+. Older versions may work, but are not + - CPython_ 3.4+, pypy_ 2.0+. Older versions may work, but are not recommended as there is no automated regression testing set up for them. - libusb-1.0_ @@ -520,8 +520,13 @@ Add support for homebrew on Apple M1. - 1.10.1 - ------ + 1.10.1 (yanked) + --------------- + + NOTE: Release yanked_ from pypi and re-released as 2.0.0. + + 2.0.0 + ----- Drop python <3.4 support. @@ -534,6 +539,19 @@ Fix objects escaping control from their parent. + 2.0.1 + ----- + + Fix a TypeError exception in USBContext.handleEvents . + + Fix an AttributeError exception in USBContext.hotplugRegisterCallback . + + Fix segfault in pypy3 when finalizing USBDevice objects . + + Source only: convert examples to python3. + + Release process: also run some examples scripts. + .. _CPython: http://www.python.org/ .. _pypy: http://pypy.org/ @@ -552,6 +570,8 @@ .. _Zadig: https://zadig.akeo.ie/ + .. _yanked: https://www.python.org/dev/peps/pep-0592/ + Keywords: usb libusb Platform: any Classifier: Intended Audience :: Developers diff -Nru python-libusb1-1.10.1/README.rst python-libusb1-2.0.1/README.rst --- python-libusb1-1.10.1/README.rst 2021-09-22 00:30:29.000000000 +0000 +++ python-libusb1-2.0.1/README.rst 2021-09-24 22:30:54.000000000 +0000 @@ -15,7 +15,7 @@ Dependencies ============ -- CPython_ 2.7+ or 3.4+, pypy_ 2.0+. Older versions may work, but are not +- CPython_ 3.4+, pypy_ 2.0+. Older versions may work, but are not recommended as there is no automated regression testing set up for them. - libusb-1.0_ @@ -510,8 +510,13 @@ Add support for homebrew on Apple M1. -1.10.1 ------- +1.10.1 (yanked) +--------------- + +NOTE: Release yanked_ from pypi and re-released as 2.0.0. + +2.0.0 +----- Drop python <3.4 support. @@ -524,6 +529,19 @@ Fix objects escaping control from their parent. +2.0.1 +----- + +Fix a TypeError exception in USBContext.handleEvents . + +Fix an AttributeError exception in USBContext.hotplugRegisterCallback . + +Fix segfault in pypy3 when finalizing USBDevice objects . + +Source only: convert examples to python3. + +Release process: also run some examples scripts. + .. _CPython: http://www.python.org/ .. _pypy: http://pypy.org/ @@ -541,3 +559,5 @@ .. _libusb1.0 documentation: http://libusb.sourceforge.net/api-1.0/ .. _Zadig: https://zadig.akeo.ie/ + +.. _yanked: https://www.python.org/dev/peps/pep-0592/ diff -Nru python-libusb1-1.10.1/usb1/__init__.py python-libusb1-2.0.1/usb1/__init__.py --- python-libusb1-1.10.1/usb1/__init__.py 2021-09-22 00:16:11.000000000 +0000 +++ python-libusb1-2.0.1/usb1/__init__.py 2021-09-24 22:30:54.000000000 +0000 @@ -2079,7 +2079,7 @@ __poll_cb_user_data = None __auto_open = True __has_pollfd_finalizer = False - __mayRaiseUSBError = mayRaiseUSBError + __mayRaiseUSBError = staticmethod(mayRaiseUSBError) __libusb_handle_events = None # pylint: disable=no-self-argument,protected-access @@ -2255,14 +2255,9 @@ try: for device_p in device_p_p[:device_list_len]: try: - # Instanciate our own libusb_device_p object so we can free - # libusb-provided device list. Is this a bug in ctypes that - # it doesn't copy pointer value (=pointed memory address) ? - # At least, it's not so convenient and forces using such - # weird code. device = USBDevice( context=self, - device_p=libusb_device_p(device_p.contents), + device_p=device_p, registerFinalizer=self.__registerFinalizer, unregisterFinalizer=self.__unregisterFinalizer, can_load_configuration=True, @@ -2608,8 +2603,9 @@ it cannot call any synchronous libusb function. """ def wrapped_callback(context_p, device_p, event, _): - assert addressof(context_p.contents) == addressof( - self.__context_p.contents), (context_p, self.__context_p) + assert context_p == self.__context_p.value, ( + context_p, self.__context_p, + ) device = USBDevice( context=self, device_p=device_p, diff -Nru python-libusb1-1.10.1/usb1/_libusb1.py python-libusb1-2.0.1/usb1/_libusb1.py --- python-libusb1-1.10.1/usb1/_libusb1.py 2021-09-22 00:16:11.000000000 +0000 +++ python-libusb1-2.0.1/usb1/_libusb1.py 2021-09-24 22:30:54.000000000 +0000 @@ -971,9 +971,10 @@ # 1, and libusb_free_device_list() can optionally decrease the reference count # on all devices in the list. libusb_open() adds another reference which is # later destroyed by libusb_close(). -class libusb_device(Structure): - pass -libusb_device_p = POINTER(libusb_device) +#class libusb_device(Structure): +# pass +#libusb_device_p = POINTER(libusb_device) +libusb_device_p = c_void_p # Any pointer is fine libusb_device_p_p = POINTER(libusb_device_p) libusb_device_p_p_p = POINTER(libusb_device_p_p) diff -Nru python-libusb1-1.10.1/usb1/_version.py python-libusb1-2.0.1/usb1/_version.py --- python-libusb1-1.10.1/usb1/_version.py 2021-09-22 00:30:44.032914000 +0000 +++ python-libusb1-2.0.1/usb1/_version.py 2021-09-24 22:31:43.440719800 +0000 @@ -9,11 +9,11 @@ version_json = ''' { - "date": "2021-09-22T00:30:06+0000", + "date": "2021-09-24T22:30:22+0000", "dirty": false, "error": null, - "full-revisionid": "d4642715a24e9ec0005e1cc2b144cbec03c4de48", - "version": "1.10.1" + "full-revisionid": "094ae7d8e45cded9aa0aadb1fde7f37bf6240656", + "version": "2.0.1" } ''' # END VERSION_JSON