Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pyscard for openSUSE:Factory checked in at 2022-09-30 17:58:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pyscard (Old) and /work/SRC/openSUSE:Factory/.python-pyscard.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pyscard" Fri Sep 30 17:58:09 2022 rev:14 rq:1007095 version:2.0.5 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pyscard/python-pyscard.changes 2022-04-23 19:49:31.331236997 +0200 +++ /work/SRC/openSUSE:Factory/.python-pyscard.new.2275/python-pyscard.changes 2022-09-30 17:58:27.609333994 +0200 @@ -1,0 +2,12 @@ +Thu Sep 29 18:26:31 UTC 2022 - Martin Hauke <mar...@gmx.de> + +- Update to version 2.0.5 + * no functional changes +- Update to version 2.0.4 + * Fix a problem on PCSCCardConnection.disconnect + * Add support of BaseSCardException(hresult) format + * Do not use deprecated distutils anymore +- Update to version 2.0.3 + * PCSCExceptions: include error code in the message + +------------------------------------------------------------------- Old: ---- pyscard-2.0.2.tar.gz New: ---- pyscard-2.0.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pyscard.spec ++++++ --- /var/tmp/diff_new_pack.8reYVX/_old 2022-09-30 17:58:28.037334910 +0200 +++ /var/tmp/diff_new_pack.8reYVX/_new 2022-09-30 17:58:28.041334918 +0200 @@ -20,7 +20,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define modname pyscard Name: python-pyscard -Version: 2.0.2 +Version: 2.0.5 Release: 0 Summary: Python module adding smart card support License: LGPL-2.0-or-later ++++++ pyscard-2.0.2.tar.gz -> pyscard-2.0.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/ChangeLog new/pyscard-2.0.5/ChangeLog --- old/pyscard-2.0.2/ChangeLog 2021-09-22 22:37:46.000000000 +0200 +++ new/pyscard-2.0.5/ChangeLog 2022-09-28 13:59:52.000000000 +0200 @@ -1,3 +1,19 @@ +2.0.5 (Septembre 2022) +====================== + * New version just because I failed the previous upload to https://pypi.org/ + +2.0.4 (August 2022) +================== + * Fix a problem on PCSCCardConnection.disconnect + * Add support of BaseSCardException(hresult) format + * Do not use deprecated distutils anymore + +2.0.3 (March 2022) +================== + * PCSCExceptions: include error code in the message + * getReaderNames(): fix Windows 10 issue when the last reader is + disconnected + 2.0.2 (September 2021) ====================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/PKG-INFO new/pyscard-2.0.5/PKG-INFO --- old/pyscard-2.0.2/PKG-INFO 2021-09-22 22:40:37.127004600 +0200 +++ new/pyscard-2.0.5/PKG-INFO 2022-09-28 14:06:25.013272500 +0200 @@ -1,13 +1,11 @@ Metadata-Version: 2.1 Name: pyscard -Version: 2.0.2 +Version: 2.0.5 Summary: Smartcard module for Python. Home-page: https://github.com/LudovicRousseau/pyscard +Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%202.0.5/pyscard-2.0.5.tar.gz/download Author: Ludovic Rousseau Author-email: ludovic.rouss...@free.fr -License: UNKNOWN -Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%202.0.2/pyscard-2.0.2.tar.gz/download -Description: Smartcard package for Python Platform: linux Platform: win32 Classifier: Development Status :: 5 - Production/Stable @@ -16,14 +14,17 @@ Classifier: Operating System :: Unix Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: MacOS :: MacOS X -Classifier: Programming Language :: Python :: 2.6 -Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Topic :: Security Provides-Extra: Gui Provides-Extra: Pyro +License-File: LICENSE + +Smartcard package for Python diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/README.md new/pyscard-2.0.5/README.md --- old/pyscard-2.0.2/README.md 2021-06-11 09:57:47.000000000 +0200 +++ new/pyscard-2.0.5/README.md 2021-12-29 18:24:03.000000000 +0100 @@ -17,8 +17,8 @@ Continuous Integration status ----------------------------- -Travis CI: [](https://travis-ci.com/LudovicRousseau/pyscard) - AppVeyor: [](https://ci.appveyor.com/project/LudovicRousseau/pyscard) Coveralls: [](https://coveralls.io/github/LudovicRousseau/pyscard?branch=master) + +lgtm: [](https://lgtm.com/projects/g/LudovicRousseau/pyscard/alerts/) [](https://lgtm.com/projects/g/LudovicRousseau/pyscard/context:cpp) [](https://lgtm.com/projects/g/LudovicRousseau/pyscard/context:python) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/pyscard.egg-info/PKG-INFO new/pyscard-2.0.5/pyscard.egg-info/PKG-INFO --- old/pyscard-2.0.2/pyscard.egg-info/PKG-INFO 2021-09-22 22:40:37.000000000 +0200 +++ new/pyscard-2.0.5/pyscard.egg-info/PKG-INFO 2022-09-28 14:06:24.000000000 +0200 @@ -1,13 +1,11 @@ Metadata-Version: 2.1 Name: pyscard -Version: 2.0.2 +Version: 2.0.5 Summary: Smartcard module for Python. Home-page: https://github.com/LudovicRousseau/pyscard +Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%202.0.5/pyscard-2.0.5.tar.gz/download Author: Ludovic Rousseau Author-email: ludovic.rouss...@free.fr -License: UNKNOWN -Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%202.0.2/pyscard-2.0.2.tar.gz/download -Description: Smartcard package for Python Platform: linux Platform: win32 Classifier: Development Status :: 5 - Production/Stable @@ -16,14 +14,17 @@ Classifier: Operating System :: Unix Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: MacOS :: MacOS X -Classifier: Programming Language :: Python :: 2.6 -Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Topic :: Security Provides-Extra: Gui Provides-Extra: Pyro +License-File: LICENSE + +Smartcard package for Python diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/pyscard.egg-info/SOURCES.txt new/pyscard-2.0.5/pyscard.egg-info/SOURCES.txt --- old/pyscard-2.0.2/pyscard.egg-info/SOURCES.txt 2021-09-22 22:40:37.000000000 +0200 +++ new/pyscard-2.0.5/pyscard.egg-info/SOURCES.txt 2022-09-28 14:06:24.000000000 +0200 @@ -69,7 +69,6 @@ pyscard.egg-info/PKG-INFO pyscard.egg-info/SOURCES.txt pyscard.egg-info/dependency_links.txt -pyscard.egg-info/pbr.json pyscard.egg-info/requires.txt pyscard.egg-info/top_level.txt smartcard/Examples/framework/sample_ATR.py @@ -147,7 +146,6 @@ smartcard/test/framework/testcase_ulist.py smartcard/test/framework/testcase_utils.py smartcard/test/framework/testsuite_framework.py -smartcard/test/frameworkpcsc/local_config.py smartcard/test/frameworkpcsc/readme.txt smartcard/test/frameworkpcsc/testcase_pcscreadergroups.py smartcard/test/frameworkpcsc/testsuite_frameworkpcsc.py @@ -167,5 +165,6 @@ test/__init__.py test/test_ATR.py test/test_Exceptions.py +test/test_PCSCExceptions.py test/test_SCardGetErrorMessage.py test/test_util.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/pyscard.egg-info/pbr.json new/pyscard-2.0.5/pyscard.egg-info/pbr.json --- old/pyscard-2.0.2/pyscard.egg-info/pbr.json 2019-10-22 18:44:27.000000000 +0200 +++ new/pyscard-2.0.5/pyscard.egg-info/pbr.json 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -{"is_release": false, "git_version": "7065afc"} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/setup.py new/pyscard-2.0.5/setup.py --- old/pyscard-2.0.2/setup.py 2021-09-22 22:37:46.000000000 +0200 +++ new/pyscard-2.0.5/setup.py 2022-09-28 13:58:30.000000000 +0200 @@ -1,5 +1,5 @@ #! /usr/bin/env python3 -"""Setup file for distutils +"""Setup file for setuptools __author__ = "http://www.gemalto.com" @@ -25,52 +25,44 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ -from distutils.util import get_platform +import platform +import shlex +import subprocess import sys from setuptools import setup, Extension from setuptools.command.build_py import build_py -if sys.version_info[0:2] < (2, 6): - raise RuntimeError("pyscard requires Python 2.6+ to build.") - platform_include_dirs = [] platform_sources = [] platform_libraries = [] platform_extra_compile_args = [] # ['-ggdb', '-O0'] platform_extra_link_args = [] # ['-ggdb'] -if get_platform() in ('win32', 'win-amd64'): +if platform.system() == 'Windows': platform__cc_defines = [('WIN32', '100')] platform_swig_opts = ['-DWIN32'] platform_sources = ['smartcard/scard/scard.rc'] platform_libraries = ['winscard'] -elif 'cygwin-' in get_platform(): - platform__cc_defines = [('WIN32', '100')] - platform_swig_opts = ['-DWIN32'] - platform_libraries = ['winscard'] - -elif 'macosx-' in get_platform(): - if 'macosx-10.6' in get_platform(): - macosx_define = '__LEOPARD__' # Snow Leopard, Python 2.6 - else: - macosx_define = '__LION__' # Lion (and above), Python 2.7 +elif platform.system() == 'Darwin': platform__cc_defines = [('PCSCLITE', '1'), - ('__APPLE__', '1'), - (macosx_define, '1')] - platform_swig_opts = ['-DPCSCLITE', '-D__APPLE__', '-D' + macosx_define] + ('__APPLE__', '1')] + platform_swig_opts = ['-DPCSCLITE', '-D__APPLE__'] # Other (GNU/Linux, etc.) # else: platform__cc_defines = [('PCSCLITE', '1')] platform_swig_opts = ['-DPCSCLITE'] - platform_include_dirs = ['/usr/include/PCSC', '/usr/local/include/PCSC'] - + try: + pkg_config_cflags = subprocess.check_output(['pkg-config', '--cflags', 'libpcsclite']) + platform_extra_compile_args += shlex.split(pkg_config_cflags.decode()) + except: + platform_include_dirs = ['/usr/include/PCSC', '/usr/local/include/PCSC'] -VERSION_INFO = (2, 0, 2, 0) +VERSION_INFO = (2, 0, 5, 0) VERSION_STR = '%i.%i.%i' % VERSION_INFO[:3] VERSION_ALT = '%i,%01i,%01i,%04i' % VERSION_INFO @@ -133,20 +125,19 @@ 'classifiers': [ 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: GNU Lesser General Public License v2 ' - 'or later (LGPLv2+)', + 'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)', 'Intended Audience :: Developers', 'Operating System :: Unix', 'Operating System :: Microsoft :: Windows', 'Operating System :: MacOS :: MacOS X', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Topic :: Security', ] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/CardService.py new/pyscard-2.0.5/smartcard/CardService.py --- old/pyscard-2.0.2/smartcard/CardService.py 2021-06-11 10:16:18.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/CardService.py 2021-12-29 18:24:03.000000000 +0100 @@ -64,5 +64,5 @@ cs = CardService(cc) cs.connection.connect() data, sw1, sw2 = cs.connection.transmit(SELECT + DF_TELECOM) - print("%X %X" % (sw1, sw2)) + print("{:X} {:X}".format(sw1, sw2)) cs.connection.disconnect() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/CardType.py new/pyscard-2.0.5/smartcard/CardType.py --- old/pyscard-2.0.2/smartcard/CardType.py 2021-06-11 10:16:21.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/CardType.py 2021-11-07 16:41:51.000000000 +0100 @@ -50,6 +50,9 @@ class AnyCardType(CardType): """The AnyCardType matches any card.""" + def __init__(self): + super().__init__() + def matches(self, atr, reader=None): """Always returns true, i.e. AnyCardType matches any card. @@ -67,6 +70,7 @@ @param mask: an optional mask to be applied to the ATR for L{CardType} matching default is None """ + super().__init__() self.atr = list(atr) self.mask = mask if mask is None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/Examples/framework/sample_CustomErrorChecker.py new/pyscard-2.0.5/smartcard/Examples/framework/sample_CustomErrorChecker.py --- old/pyscard-2.0.2/smartcard/Examples/framework/sample_CustomErrorChecker.py 2021-06-11 10:18:01.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/Examples/framework/sample_CustomErrorChecker.py 2021-12-29 18:24:03.000000000 +0100 @@ -77,7 +77,7 @@ apdu = GET_RESPONSE + [sw2] response, sw1, sw2 = cardservice.connection.transmit(apdu) except SWException as e: - print(e, "%x %x" % (e.sw1, e.sw2)) + print(e, "{:x} {:x}".format(e.sw1, e.sw2)) cardservice.connection.disconnect() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/Examples/framework/sample_TransmitCardObserver.py new/pyscard-2.0.5/smartcard/Examples/framework/sample_TransmitCardObserver.py --- old/pyscard-2.0.2/smartcard/Examples/framework/sample_TransmitCardObserver.py 2021-06-11 10:18:20.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/Examples/framework/sample_TransmitCardObserver.py 2021-12-29 18:24:03.000000000 +0100 @@ -50,7 +50,7 @@ card.connection.connect() response, sw1, sw2 = card.connection.transmit( SELECT_DF_TELECOM) - print("%.2x %.2x" % (sw1, sw2)) + print("{:.2x} {:.2x}".format(sw1, sw2)) for card in removedcards: print("-Removed: ", toHexString(card.atr)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/Examples/scard-api/sample_control.py new/pyscard-2.0.5/smartcard/Examples/scard-api/sample_control.py --- old/pyscard-2.0.2/smartcard/Examples/scard-api/sample_control.py 2021-06-11 10:18:24.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/Examples/scard-api/sample_control.py 2021-12-29 18:24:03.000000000 +0100 @@ -26,7 +26,7 @@ """ from smartcard.scard import * -from smartcard.util import toBytes +from smartcard.util import toBytes, toHexString, toASCIIString try: hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) @@ -68,24 +68,18 @@ raise error( 'SCardControl failed: ' + SCardGetErrorMessage(hresult)) - r = "" - for i in range(len(response)): - r += "%c" % response[i] - print('SCARD_ATTR_VENDOR_NAME:', r) + print('SCARD_ATTR_VENDOR_NAME:', toASCIIString(response)) elif 'pcsclite' == resourceManager: - # get firmware on Gemplus readers + # get feature request hresult, response = SCardControl( hcard, - SCARD_CTL_CODE(1), - [0x02]) + SCARD_CTL_CODE(3400), + []) if hresult != SCARD_S_SUCCESS: raise error( 'SCardControl failed: ' + SCardGetErrorMessage(hresult)) - r = "" - for i in range(len(response)): - r += "%c" % response[i] - print('Control:', r) + print('CM_IOCTL_GET_FEATURE_REQUEST:', toHexString(response)) finally: hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD) if hresult != SCARD_S_SUCCESS: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/Examples/simple/simpleAPDU.py new/pyscard-2.0.5/smartcard/Examples/simple/simpleAPDU.py --- old/pyscard-2.0.2/smartcard/Examples/simple/simpleAPDU.py 2021-06-11 10:19:00.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/Examples/simple/simpleAPDU.py 2021-12-29 18:24:03.000000000 +0100 @@ -47,7 +47,7 @@ connection.connect() data, sw1, sw2 = connection.transmit(SELECT_APPLET) - print("Select Applet: %02X %02X" % (sw1, sw2)) + print("Select Applet: {:02X} {:02X}".format(sw1, sw2)) data, sw1, sw2 = connection.transmit(GET_TIME) - print("Get Time: %02X %02X" % (sw1, sw2)) + print("Get Time: {:02X} {:02X}".format(sw1, sw2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/Exceptions.py new/pyscard-2.0.5/smartcard/Exceptions.py --- old/pyscard-2.0.2/smartcard/Exceptions.py 2021-09-22 22:37:46.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/Exceptions.py 2021-12-29 18:24:03.000000000 +0100 @@ -45,7 +45,7 @@ if hresult < 0: # convert 0x-7FEFFFE3 into 0x8010001D hresult += 0x100000000 - text += ": %s (0x%08X)" % (SCardGetErrorMessage(self.hresult), hresult) + text += ": {} (0x{:08X})".format(SCardGetErrorMessage(self.hresult), hresult) return text diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/PassThruCardService.py new/pyscard-2.0.5/smartcard/PassThruCardService.py --- old/pyscard-2.0.2/smartcard/PassThruCardService.py 2021-06-11 10:16:45.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/PassThruCardService.py 2021-12-29 18:24:03.000000000 +0100 @@ -57,5 +57,5 @@ cs = PassThruCardService(cc) cs.connection.connect() data, sw1, sw2 = cs.connection.transmit(SELECT + DF_TELECOM) - print("%X %X" % (sw1, sw2)) + print("{:X} {:X}".format(sw1, sw2)) cs.connection.disconnect() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pcsc/PCSCCardConnection.py new/pyscard-2.0.5/smartcard/pcsc/PCSCCardConnection.py --- old/pyscard-2.0.2/smartcard/pcsc/PCSCCardConnection.py 2021-06-11 10:19:48.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pcsc/PCSCCardConnection.py 2022-05-07 15:17:06.000000000 +0200 @@ -32,7 +32,7 @@ def translateprotocolmask(protocol): """Translate CardConnection protocol mask into PCSC protocol mask.""" pcscprotocol = 0 - if None != protocol: + if protocol is not None: if CardConnection.T0_protocol & protocol: pcscprotocol |= SCARD_PROTOCOL_T0 if CardConnection.T1_protocol & protocol: @@ -47,7 +47,7 @@ def translateprotocolheader(protocol): """Translate protocol into PCSC protocol header.""" pcscprotocol = 0 - if None != protocol: + if protocol is not None: if CardConnection.T0_protocol == protocol: pcscprotocol = SCARD_PCI_T0 if CardConnection.T1_protocol == protocol: @@ -86,7 +86,7 @@ # can disappear before __del__ is called self.disconnect() hresult = SCardReleaseContext(self.hcontext) - if hresult != 0: + if hresult != 0 and hresult != SCARD_E_INVALID_VALUE: raise CardConnectionException( 'Failed to release context: ' + \ SCardGetErrorMessage(hresult)) @@ -104,11 +104,11 @@ if 0 == pcscprotocol: pcscprotocol = self.getProtocol() - if mode == None: + if mode is None: mode = SCARD_SHARE_SHARED # store the way to dispose the card - if disposition == None: + if disposition is None: disposition = SCARD_UNPOWER_CARD self.disposition = disposition @@ -146,18 +146,18 @@ If disposition is not specified, do a warm reset (SCARD_RESET_CARD)""" CardConnection.reconnect(self, protocol) - if self.hcard == None: + if self.hcard is None: raise CardConnectionException('Card not connected') pcscprotocol = translateprotocolmask(protocol) if 0 == pcscprotocol: pcscprotocol = self.getProtocol() - if mode == None: + if mode is None: mode = SCARD_SHARE_SHARED # store the way to dispose the card - if disposition == None: + if disposition is None: disposition = SCARD_RESET_CARD self.disposition = disposition @@ -195,18 +195,18 @@ CardConnection.disconnect(self) except TypeError: pass - if None != self.hcard: + if self.hcard is not None: hresult = SCardDisconnect(self.hcard, self.disposition) + self.hcard = None if hresult != 0: raise CardConnectionException( 'Failed to disconnect: ' + \ SCardGetErrorMessage(hresult)) - self.hcard = None def getATR(self): """Return card ATR""" CardConnection.getATR(self) - if None == self.hcard: + if self.hcard is None: raise CardConnectionException('Card not connected') hresult, reader, state, protocol, atr = SCardStatus(self.hcard) if hresult != 0: @@ -229,7 +229,7 @@ sw2 is status word 2, e.g. 0x1A response are the response bytes excluding status words """ - if None == protocol: + if protocol is None: protocol = self.getProtocol() CardConnection.doTransmit(self, bytes, protocol) pcscprotocolheader = translateprotocolheader(protocol) @@ -239,7 +239,7 @@ 'CardConnection.T0_protocol, ' + \ 'CardConnection.T1_protocol, or ' + \ 'CardConnection.RAW_protocol') - if None == self.hcard: + if self.hcard is None: raise CardConnectionException('Card not connected') hresult, response = SCardTransmit( self.hcard, pcscprotocolheader, bytes) @@ -303,4 +303,3 @@ print("%r %x %x" % cc.transmit(SELECT + DF_TELECOM)) print(cc.control(CM_IOCTL_GET_FEATURE_REQUEST, [])) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pcsc/PCSCCardRequest.py new/pyscard-2.0.5/smartcard/pcsc/PCSCCardRequest.py --- old/pyscard-2.0.2/smartcard/pcsc/PCSCCardRequest.py 2021-09-22 22:37:46.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pcsc/PCSCCardRequest.py 2022-01-02 18:05:39.000000000 +0100 @@ -81,7 +81,7 @@ self.hcontext = PCSCContext().getContext() def getReaderNames(self): - """Returns the list or PCSC readers on which to wait for cards.""" + """Returns the list of PCSC readers on which to wait for cards.""" # renew the context in case PC/SC was stopped # this happens on Windows when the last reader is disconnected @@ -89,7 +89,10 @@ # get inserted readers hresult, pcscreaders = SCardListReaders(self.hcontext, []) - if hresult in [SCARD_E_NO_READERS_AVAILABLE, SCARD_E_SERVICE_STOPPED]: + if SCARD_E_SERVICE_STOPPED == hresult: + self.hcontext = PCSCContext().renewContext() + hresult, pcscreaders = SCardListReaders(self.hcontext, []) + if SCARD_E_NO_READERS_AVAILABLE == hresult: return [] if SCARD_S_SUCCESS != hresult: raise ListReadersException(hresult) @@ -358,4 +361,3 @@ cs.connection.connect() print(cs.connection.getReader() + ' ' + toHexString(cs.connection.getATR())) cs.connection.disconnect() - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pcsc/PCSCExceptions.py new/pyscard-2.0.5/smartcard/pcsc/PCSCExceptions.py --- old/pyscard-2.0.2/smartcard/pcsc/PCSCExceptions.py 2019-10-22 18:44:26.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pcsc/PCSCExceptions.py 2022-08-23 21:47:00.000000000 +0200 @@ -36,65 +36,69 @@ """ - def __init__(self, hresult): + def __init__(self, hresult=-1, message="", *args): """Constructor that stores the pcsc error status.""" + if not message: + message = "scard exception" + super().__init__(message, *args) + self.message = message self.hresult = hresult def __str__(self): """Returns a string representation of the exception.""" - return repr("scard exception: " + - smartcard.scard.SCardGetErrorMessage(self.hresult)) + text = super().__str__() + if self.hresult != -1: + hresult = self.hresult + if hresult < 0: + # convert 0x-7FEFFFE3 into 0x8010001D + hresult += 0x100000000 + text += ": {} (0x{:08X})".format(smartcard.scard.SCardGetErrorMessage(self.hresult), hresult) + return text class AddReaderToGroupException(BaseSCardException): """Raised when scard fails to add a new reader to a PCSC reader group.""" def __init__(self, hresult, readername="", groupname=""): - BaseSCardException.__init__(self, hresult) + super().__init__(message='Failed to add reader: ' + readername + + ' to group: ' + groupname, + hresult=hresult) self.readername = readername self.groupname = groupname - def __str__(self): - return repr('Failure to add reader: ' + self.readername + - ' to group: ' + self.groupname + ' ' + - smartcard.scard.SCardGetErrorMessage(self.hresult)) - class EstablishContextException(BaseSCardException): """Raised when scard failed to establish context with PCSC.""" - def __str__(self): - """Returns a string representation of the exception.""" - return repr('Failure to establish context: ' + - smartcard.scard.SCardGetErrorMessage(self.hresult)) + def __init__(self, hresult): + super().__init__(message='Failed to establish context', + hresult=hresult) class ListReadersException(BaseSCardException): """Raised when scard failed to list readers.""" - def __str__(self): - return repr('Failure to list readers: ' + - smartcard.scard.SCardGetErrorMessage(self.hresult)) + def __init__(self, hresult): + super().__init__(message='Failed to list readers', + hresult=hresult) class IntroduceReaderException(BaseSCardException): """Raised when scard fails to introduce a new reader to PCSC.""" def __init__(self, hresult, readername=""): - BaseSCardException.__init__(self, hresult) + super().__init__( + message='Failed to introduce a new reader: ' + readername, + hresult=hresult) self.readername = readername - def __str__(self): - return repr('Failure to introduce a new reader: ' + self.readername - + ' ' + smartcard.scard.SCardGetErrorMessage(self.hresult)) - class ReleaseContextException(BaseSCardException): """Raised when scard failed to release PCSC context.""" - def __str__(self): - return repr('Failure to release context: ' + - smartcard.scard.SCardGetErrorMessage(self.hresult)) + def __init__(self, hresult): + super().__init__(message='Failed to release context', + hresult=hresult) class RemoveReaderFromGroupException(BaseSCardException): @@ -104,15 +108,13 @@ BaseSCardException.__init__(self, hresult) self.readername = readername self.groupname = groupname + super().__init__(message='Failed to remove reader: ' + readername + + ' from group: ' + groupname, + hresult=hresult) - def __str__(self): - return repr('Failure to remove reader: ' + self.readername + - ' from group: ' + self.groupname + ' ' + - smartcard.scard.SCardGetErrorMessage(self.hresult)) if __name__ == "__main__": try: raise EstablishContextException(smartcard.scard.SCARD_E_NO_MEMORY) except BaseSCardException as exc: print(exc) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pcsc/PCSCPart10.py new/pyscard-2.0.5/smartcard/pcsc/PCSCPart10.py --- old/pyscard-2.0.2/smartcard/pcsc/PCSCPart10.py 2021-06-11 10:19:59.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pcsc/PCSCPart10.py 2021-12-29 18:24:03.000000000 +0100 @@ -263,9 +263,9 @@ properties = getPinProperties(cc) print("\nPinProperties:") for k, v in list(properties.items()): - print(" %s: %s" % (k, v)) + print(" {}: {}".format(k, v)) print("\nTlvProperties:") properties = getTlvProperties(cc) for k, v in list(properties.items()): - print(" %s: %s" % (k, v)) + print(" {}: {}".format(k, v)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pcsc/PCSCReader.py new/pyscard-2.0.5/smartcard/pcsc/PCSCReader.py --- old/pyscard-2.0.2/smartcard/pcsc/PCSCReader.py 2021-06-11 10:20:04.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pcsc/PCSCReader.py 2021-12-29 18:24:03.000000000 +0100 @@ -132,6 +132,6 @@ connection.connect() print(toHexString(connection.getATR())) data, sw1, sw2 = connection.transmit(SELECT + DF_TELECOM) - print("%02X %02X" % (sw1, sw2)) + print("{:02X} {:02X}".format(sw1, sw2)) except NoCardException: print('no card in reader') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pcsc/PCSCReaderGroups.py new/pyscard-2.0.5/smartcard/pcsc/PCSCReaderGroups.py --- old/pyscard-2.0.2/smartcard/pcsc/PCSCReaderGroups.py 2021-06-11 10:20:02.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pcsc/PCSCReaderGroups.py 2021-11-07 16:41:51.000000000 +0100 @@ -113,4 +113,3 @@ if __name__ == '__main__': print(PCSCReaderGroups().getreadergroups()) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/pyro/PyroReader.py new/pyscard-2.0.5/smartcard/pyro/PyroReader.py --- old/pyscard-2.0.2/smartcard/pyro/PyroReader.py 2021-06-11 10:20:30.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/pyro/PyroReader.py 2021-12-29 18:24:03.000000000 +0100 @@ -34,6 +34,7 @@ def __init__(self, readername): """Constructs a new Remote Reader client implementation from a Pyro URI.""" + super().__init__(readername) ns = Pyro.naming.NameServerLocator().getNS() self.uri = ns.resolve(':pyscard.smartcard.readers.' + readername) self.reader = Pyro.core.getAttrProxyForURI(self.uri) @@ -85,6 +86,6 @@ connection.connect() print(toHexString(connection.getATR())) data, sw1, sw2 = connection.transmit(SELECT + DF_TELECOM) - print("%X %X" % (sw1, sw2)) + print("{:X} {:X}".format(sw1, sw2)) except NoCardException as x: print('no card in reader') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/reader/ReaderGroups.py new/pyscard-2.0.5/smartcard/reader/ReaderGroups.py --- old/pyscard-2.0.2/smartcard/reader/ReaderGroups.py 2021-06-11 10:21:18.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/reader/ReaderGroups.py 2021-11-07 16:41:51.000000000 +0100 @@ -119,4 +119,3 @@ if __name__ == '__main__': print(readergroups()) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/scard/scard.i new/pyscard-2.0.5/smartcard/scard/scard.i --- old/pyscard-2.0.2/smartcard/scard/scard.i 2021-09-22 22:37:46.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/scard/scard.i 2022-08-23 21:47:00.000000000 +0200 @@ -1876,12 +1876,7 @@ #ifdef PCSCLITE %constant char* resourceManager = "pcsclite" ; #ifdef __APPLE__ - #ifdef __LEOPARD__ - %constant char* resourceManagerSubType = "pcsclite-leopard" ; - #endif //__LEOPARD__ - #ifdef __LION__ - %constant char* resourceManagerSubType = "pcsclite-lion" ; - #endif //__LION_ + %constant char* resourceManagerSubType = "pcsclite-lion" ; #else // !__APPLE__ %constant char* resourceManagerSubType = "pcsclite-linux" ; #endif // __APPLE__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/sw/ISO7816_4ErrorChecker.py new/pyscard-2.0.5/smartcard/sw/ISO7816_4ErrorChecker.py --- old/pyscard-2.0.2/smartcard/sw/ISO7816_4ErrorChecker.py 2021-06-11 10:21:36.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/sw/ISO7816_4ErrorChecker.py 2021-12-29 18:24:03.000000000 +0100 @@ -156,4 +156,4 @@ try: ecs([], 0x6b, 0x00) except smartcard.sw.SWExceptions.CheckingErrorException as e: - print(str(e) + " %x %x" % (e.sw1, e.sw2)) + print(str(e) + " {:x} {:x}".format(e.sw1, e.sw2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/sw/ISO7816_4_SW1ErrorChecker.py new/pyscard-2.0.5/smartcard/sw/ISO7816_4_SW1ErrorChecker.py --- old/pyscard-2.0.2/smartcard/sw/ISO7816_4_SW1ErrorChecker.py 2021-06-11 10:21:40.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/sw/ISO7816_4_SW1ErrorChecker.py 2021-12-29 18:24:03.000000000 +0100 @@ -82,4 +82,4 @@ try: ecs([], 0x66, 0x80) except smartcard.sw.SWExceptions.SecurityRelatedException as e: - print(str(e) + " %x %x" % (e.sw1, e.sw2)) + print(str(e) + " {:x} {:x}".format(e.sw1, e.sw2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/sw/ISO7816_8ErrorChecker.py new/pyscard-2.0.5/smartcard/sw/ISO7816_8ErrorChecker.py --- old/pyscard-2.0.2/smartcard/sw/ISO7816_8ErrorChecker.py 2021-06-11 10:21:42.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/sw/ISO7816_8ErrorChecker.py 2021-12-29 18:24:03.000000000 +0100 @@ -128,4 +128,4 @@ try: ecs([], 0x66, 0x87) except smartcard.sw.SWExceptions.SecurityRelatedException as e: - print(str(e) + " %x %x" % (e.sw1, e.sw2)) + print(str(e) + " {:x} {:x}".format(e.sw1, e.sw2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/sw/ISO7816_9ErrorChecker.py new/pyscard-2.0.5/smartcard/sw/ISO7816_9ErrorChecker.py --- old/pyscard-2.0.2/smartcard/sw/ISO7816_9ErrorChecker.py 2021-06-11 10:21:44.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/sw/ISO7816_9ErrorChecker.py 2021-12-29 18:24:03.000000000 +0100 @@ -94,4 +94,4 @@ try: ecs([], 0x6A, 0x8A) except smartcard.sw.SWExceptions.CheckingErrorException as e: - print(str(e) + " %x %x" % (e.sw1, e.sw2)) + print(str(e) + " {:x} {:x}".format(e.sw1, e.sw2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/sw/op21_ErrorChecker.py new/pyscard-2.0.5/smartcard/sw/op21_ErrorChecker.py --- old/pyscard-2.0.2/smartcard/sw/op21_ErrorChecker.py 2021-06-11 10:21:47.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/sw/op21_ErrorChecker.py 2021-12-29 18:24:03.000000000 +0100 @@ -122,4 +122,4 @@ try: ecs([], 0x94, 0x84) except smartcard.sw.SWExceptions.CheckingErrorException as e: - print(str(e) + "%x %x" % (e.sw1, e.sw2)) + print(str(e) + "{:x} {:x}".format(e.sw1, e.sw2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/local_config.py new/pyscard-2.0.5/smartcard/test/framework/local_config.py --- old/pyscard-2.0.2/smartcard/test/framework/local_config.py 2019-10-22 18:44:23.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/local_config.py 2021-03-18 18:21:40.000000000 +0100 @@ -1,6 +1,6 @@ from smartcard.util import toHexString -expectedReaders = ['Gemalto PC Twin Reader 00 00'] -expectedATRs = [[63, 47, 0, 128, 105, 175, 2, 4, 1, 49, 0, 0, 0, 14, 131, 62, 159, 22]] +expectedReaders = ['Gemalto PC Twin Reader'] +expectedATRs = [[59, 167, 0, 64, 24, 128, 101, 162, 8, 1, 1, 82]] expectedATRinReader = {} for i in range(len(expectedReaders)): expectedATRinReader[expectedReaders[i]] = expectedATRs[i] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_ATR.py new/pyscard-2.0.5/smartcard/test/framework/testcase_ATR.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_ATR.py 2021-06-11 10:22:31.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_ATR.py 2021-12-29 18:24:03.000000000 +0100 @@ -65,7 +65,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_ATR) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_CAtr.py new/pyscard-2.0.5/smartcard/test/framework/testcase_CAtr.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_CAtr.py 2021-06-11 10:07:27.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_CAtr.py 2021-12-29 18:24:03.000000000 +0100 @@ -117,7 +117,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_CAtr) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_Card.py new/pyscard-2.0.5/smartcard/test/framework/testcase_Card.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_Card.py 2021-06-11 10:23:07.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_Card.py 2021-12-29 18:24:03.000000000 +0100 @@ -77,7 +77,7 @@ expectedSWs = {"9f 1a": 1, "9f 20": 2, "6e 0": 3} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) else: self.assertRaises(NoCardException, cc.connect) @@ -96,7 +96,7 @@ expectedSWs = {"9f 1a": 1, "9f 20": 2, "6e 0": 3} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) else: self.assertRaises(NoCardException, cc.connect) @@ -117,7 +117,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_CardConnection) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_CardConnection.py new/pyscard-2.0.5/smartcard/test/framework/testcase_CardConnection.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_CardConnection.py 2021-06-11 10:22:55.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_CardConnection.py 2021-12-29 18:24:03.000000000 +0100 @@ -72,7 +72,7 @@ expectedSWs = {"9f 1a": 1, "6e 0": 2, "9f 20": 3, "9f 22": 4} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) else: self.assertRaises(NoCardException, cc.connect) cc.disconnect() @@ -90,7 +90,7 @@ expectedSWs = {"9f 1a": 1, "6e 0": 2, "9f 20": 3, "9f 22": 4} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) else: self.assertRaises(NoCardException, cc.connect) cc.disconnect() @@ -142,7 +142,7 @@ expectedSWs = {"9f 1a": 1, "6e 0": 2, "9f 20": 3, "9f 22": 4} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) else: self.assertRaises(NoCardException, cc.connect) cc.disconnect() @@ -161,7 +161,7 @@ expectedSWs = {"9f 1a": 1, "6e 0": 2, "9f 20": 3, "9f 22": 4} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) else: self.assertRaises(NoCardException, cc.connect) cc.disconnect() @@ -244,7 +244,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_CardConnection) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_CardMonitor.py new/pyscard-2.0.5/smartcard/test/framework/testcase_CardMonitor.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_CardMonitor.py 2021-06-11 10:22:29.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_CardMonitor.py 2021-12-29 18:24:03.000000000 +0100 @@ -101,7 +101,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_cardmonitorthread) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_CardRequest.py new/pyscard-2.0.5/smartcard/test/framework/testcase_CardRequest.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_CardRequest.py 2021-06-11 10:22:36.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_CardRequest.py 2021-12-29 18:24:03.000000000 +0100 @@ -139,7 +139,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_CardRequest) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_CardService.py new/pyscard-2.0.5/smartcard/test/framework/testcase_CardService.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_CardService.py 2021-06-11 10:22:33.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_CardService.py 2021-12-29 18:24:03.000000000 +0100 @@ -66,12 +66,12 @@ expectedSWs = {"9f 1a": 1, "6e 0": 2, "9f 20": 3, "9f 22": 4} self.assertEqual([], response) self.assertTrue( - "%x %x" % (sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) + "{:x} {:x}".format(sw1, sw2) in expectedSWs or "9f" == "%x" % sw1) def suite(): suite1 = unittest.makeSuite(testcase_CardService) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_CardType.py new/pyscard-2.0.5/smartcard/test/framework/testcase_CardType.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_CardType.py 2021-06-11 10:22:26.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_CardType.py 2021-12-29 18:24:03.000000000 +0100 @@ -133,7 +133,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_CardType) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_ErrorChecking.py new/pyscard-2.0.5/smartcard/test/framework/testcase_ErrorChecking.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_ErrorChecking.py 2021-06-11 10:23:00.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_ErrorChecking.py 2021-12-29 18:24:03.000000000 +0100 @@ -281,7 +281,7 @@ """Test correct exception error message.""" ecs = ISO7816_4ErrorChecker() - e = self.failUnlessRaises( + e = self.assertRaises( smartcard.sw.SWExceptions.CheckingErrorException, ecs, [], @@ -292,7 +292,7 @@ "'Status word exception: checking error - " + \ "Conditions of use not satisfied!'") - e = self.failUnlessRaises( + e = self.assertRaises( smartcard.sw.SWExceptions.CheckingErrorException, ecs, [], @@ -330,7 +330,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_ErrorChecking) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_ExclusiveCardConnection.py new/pyscard-2.0.5/smartcard/test/framework/testcase_ExclusiveCardConnection.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_ExclusiveCardConnection.py 2021-06-11 10:22:41.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_ExclusiveCardConnection.py 2021-12-29 18:24:03.000000000 +0100 @@ -128,7 +128,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_cardmonitorthread) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_readergroups.py new/pyscard-2.0.5/smartcard/test/framework/testcase_readergroups.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_readergroups.py 2021-06-11 10:07:32.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_readergroups.py 2021-12-29 18:24:03.000000000 +0100 @@ -154,7 +154,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_readergroups) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_readermonitor.py new/pyscard-2.0.5/smartcard/test/framework/testcase_readermonitor.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_readermonitor.py 2021-06-11 10:22:50.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_readermonitor.py 2021-12-29 18:24:03.000000000 +0100 @@ -100,7 +100,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_readermonitorthread) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_readermonitorstress.py new/pyscard-2.0.5/smartcard/test/framework/testcase_readermonitorstress.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_readermonitorstress.py 2021-06-11 10:07:36.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_readermonitorstress.py 2021-12-29 18:24:03.000000000 +0100 @@ -183,7 +183,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_readermonitorthread) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_readers.py new/pyscard-2.0.5/smartcard/test/framework/testcase_readers.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_readers.py 2021-06-11 10:22:47.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_readers.py 2021-12-29 18:24:03.000000000 +0100 @@ -109,7 +109,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_readers) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/framework/testcase_ulist.py new/pyscard-2.0.5/smartcard/test/framework/testcase_ulist.py --- old/pyscard-2.0.2/smartcard/test/framework/testcase_ulist.py 2021-06-11 10:07:40.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/framework/testcase_ulist.py 2021-12-29 18:24:03.000000000 +0100 @@ -181,7 +181,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_ulist) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/frameworkpcsc/local_config.py new/pyscard-2.0.5/smartcard/test/frameworkpcsc/local_config.py --- old/pyscard-2.0.2/smartcard/test/frameworkpcsc/local_config.py 2019-10-22 18:44:24.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/frameworkpcsc/local_config.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ -from smartcard.util import toHexString -expectedReaders = ['Gemalto PC Twin Reader 00 00'] -expectedATRs = [[63, 47, 0, 128, 105, 175, 2, 4, 1, 49, 0, 0, 0, 14, 131, 62, 159, 22]] -expectedATRinReader = {} -for i in range(len(expectedReaders)): - expectedATRinReader[expectedReaders[i]] = expectedATRs[i] -expectedReaderForATR = {} -for i in range(len(expectedReaders)): - expectedReaderForATR[toHexString(expectedATRs[i])] = expectedReaders[i] -expectedReaderGroups = ['SCard$DefaultReaders'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/frameworkpcsc/testcase_pcscreadergroups.py new/pyscard-2.0.5/smartcard/test/frameworkpcsc/testcase_pcscreadergroups.py --- old/pyscard-2.0.2/smartcard/test/frameworkpcsc/testcase_pcscreadergroups.py 2021-06-11 10:23:36.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/frameworkpcsc/testcase_pcscreadergroups.py 2021-12-29 18:24:03.000000000 +0100 @@ -156,7 +156,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_readergroups) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/local_config.py new/pyscard-2.0.5/smartcard/test/scard/local_config.py --- old/pyscard-2.0.2/smartcard/test/scard/local_config.py 2019-10-22 18:44:23.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/local_config.py 2021-03-18 18:20:46.000000000 +0100 @@ -1,6 +1,6 @@ from smartcard.util import toHexString -expectedReaders = ['Gemalto PC Twin Reader 00 00'] -expectedATRs = [[63, 47, 0, 128, 105, 175, 2, 4, 1, 49, 0, 0, 0, 14, 131, 62, 159, 22]] +expectedReaders = ['Gemalto PC Twin Reader'] +expectedATRs = [[59, 167, 0, 64, 24, 128, 101, 162, 8, 1, 1, 82]] expectedATRinReader = {} for i in range(len(expectedReaders)): expectedATRinReader[expectedReaders[i]] = expectedATRs[i] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_getatr.py new/pyscard-2.0.5/smartcard/test/scard/testcase_getatr.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_getatr.py 2021-06-11 10:23:29.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_getatr.py 2021-12-29 18:24:03.000000000 +0100 @@ -90,7 +90,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_getATR) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_getattrib.py new/pyscard-2.0.5/smartcard/test/scard/testcase_getattrib.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_getattrib.py 2021-06-11 10:23:15.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_getattrib.py 2021-12-29 18:24:03.000000000 +0100 @@ -107,7 +107,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_getAttrib) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_geterrormessage.py new/pyscard-2.0.5/smartcard/test/scard/testcase_geterrormessage.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_geterrormessage.py 2021-06-11 10:08:01.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_geterrormessage.py 2021-12-29 18:24:03.000000000 +0100 @@ -67,7 +67,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_geterrormessage) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_listcards.py new/pyscard-2.0.5/smartcard/test/scard/testcase_listcards.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_listcards.py 2021-06-11 10:08:02.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_listcards.py 2021-12-29 18:24:03.000000000 +0100 @@ -211,7 +211,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_listcards) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_locatecards.py new/pyscard-2.0.5/smartcard/test/scard/testcase_locatecards.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_locatecards.py 2021-06-11 10:23:22.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_locatecards.py 2021-12-29 18:24:03.000000000 +0100 @@ -118,7 +118,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_locatecards) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_readergroups.py new/pyscard-2.0.5/smartcard/test/scard/testcase_readergroups.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_readergroups.py 2021-06-11 10:23:27.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_readergroups.py 2021-12-29 18:24:03.000000000 +0100 @@ -124,7 +124,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_readergroups) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_returncodes.py new/pyscard-2.0.5/smartcard/test/scard/testcase_returncodes.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_returncodes.py 2021-06-11 10:08:08.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_returncodes.py 2021-12-29 18:24:03.000000000 +0100 @@ -103,7 +103,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_returncodes) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/test/scard/testcase_transaction.py new/pyscard-2.0.5/smartcard/test/scard/testcase_transaction.py --- old/pyscard-2.0.2/smartcard/test/scard/testcase_transaction.py 2021-06-11 10:23:24.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/test/scard/testcase_transaction.py 2021-12-29 18:24:03.000000000 +0100 @@ -96,7 +96,7 @@ def suite(): suite1 = unittest.makeSuite(testcase_transaction) - return unittest.TestSuite((suite1)) + return unittest.TestSuite(suite1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/smartcard/wx/SimpleSCardApp.py new/pyscard-2.0.5/smartcard/wx/SimpleSCardApp.py --- old/pyscard-2.0.2/smartcard/wx/SimpleSCardApp.py 2019-10-22 18:44:26.000000000 +0200 +++ new/pyscard-2.0.5/smartcard/wx/SimpleSCardApp.py 2021-12-29 18:24:03.000000000 +0100 @@ -46,7 +46,7 @@ appicon=None, pos=(-1, -1), size=(-1, -1)): - """Constructor for simple smart card application. + r"""Constructor for simple smart card application. @param appname: the application name @param apppanel: the application panel to display in the application frame @param appicon: the application icon file; the default is no icon diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/test/test_Exceptions.py new/pyscard-2.0.5/test/test_Exceptions.py --- old/pyscard-2.0.2/test/test_Exceptions.py 2021-09-22 22:37:46.000000000 +0200 +++ new/pyscard-2.0.5/test/test_Exceptions.py 2022-08-28 18:38:10.000000000 +0200 @@ -6,8 +6,9 @@ import unittest from smartcard.Exceptions import * +from smartcard.pcsc.PCSCExceptions import * from smartcard.scard import * -from distutils.util import get_platform +import platform class TestUtil(unittest.TestCase): @@ -21,14 +22,17 @@ exc = ListReadersException(0) self.assertEqual(exc.hresult, 0) text = str(exc) - if not get_platform().startswith('win'): + if platform.system() != 'Windows': self.assertEqual(text, "Failed to list readers: Command successful. (0x00000000)") exc = ListReadersException(0x42) self.assertEqual(exc.hresult, 0x42) text = str(exc) - if not get_platform().startswith('win'): - self.assertEqual(text, "Failed to list readers: Unknown error: 0x00000042 (0x00000042)") + if platform.system() != 'Windows': + expected = "Failed to list readers: Unknown error: 0x00000042 (0x00000042)" + macos_bug_expected = expected.replace("Unknown", "Unkown") + print(expected, macos_bug_expected) + self.assertIn(text, [expected, macos_bug_expected]) exc = ListReadersException(SCARD_S_SUCCESS) self.assertEqual(exc.hresult, 0) @@ -36,7 +40,7 @@ exc = ListReadersException(SCARD_E_NO_SERVICE) self.assertEqual(exc.hresult, SCARD_E_NO_SERVICE) text = str(exc) - if not get_platform().startswith('win'): + if platform.system() != 'Windows': self.assertEqual(text, "Failed to list readers: Service not available. (0x8010001D)") def test_NoReadersException(self): @@ -57,6 +61,38 @@ text = str(exc) self.assertEqual(text, "") + def test_hresult(self): + hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) + if hresult == SCARD_S_SUCCESS: + hresult, hcard, dwActiveProtocol = SCardConnect( + hcontext, "INVALID READER NAME", SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY + ) + self.assertEqual(hresult, SCARD_E_UNKNOWN_READER) + else: + self.assertEqual(hresult, SCARD_E_NO_SERVICE) + + # PCSC exceptions + def test_EstablishContextException(self): + exc= EstablishContextException(SCARD_E_NOT_TRANSACTED) + self.assertEqual(exc.hresult, SCARD_E_NOT_TRANSACTED) + text = str(exc) + if platform.system() == 'Windows': + expected = "An attempt was made to end a non-existent transaction. " + else: + expected = "Transaction failed." + expected = "Failed to establish context: " + expected + " (0x80100016)" + self.assertEqual(text, expected) + + def test_BaseSCardException(self): + exc= BaseSCardException(message="foo", hresult=SCARD_E_NOT_TRANSACTED) + self.assertEqual(exc.hresult, SCARD_E_NOT_TRANSACTED) + text = str(exc) + if platform.system() == 'Windows': + expected = "An attempt was made to end a non-existent transaction. " + else: + expected = "Transaction failed." + expected = "foo: " + expected + " (0x80100016)" + self.assertEqual(text, expected) if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/test/test_PCSCExceptions.py new/pyscard-2.0.5/test/test_PCSCExceptions.py --- old/pyscard-2.0.2/test/test_PCSCExceptions.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pyscard-2.0.5/test/test_PCSCExceptions.py 2022-08-28 18:38:10.000000000 +0200 @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- + +# to execute: +# $ cd test +# $ python -m unittest + +import unittest +from smartcard.pcsc.PCSCExceptions import * +from smartcard.scard import * +import platform + + +class TestUtil(unittest.TestCase): + + def test_ListReadersException(self): + exc = ListReadersException(0) + self.assertEqual(exc.hresult, 0) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to list readers: The operation completed successfully. (0x00000000)" + else: + expected = "Failed to list readers: Command successful. (0x00000000)" + self.assertEqual(text, expected) + + exc = ListReadersException(0x42) + self.assertEqual(exc.hresult, 0x42) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to list readers: The network resource type is not correct. (0x00000042)" + else: + expected = "Failed to list readers: Unknown error: 0x00000042 (0x00000042)" + macos_bug_expected = expected.replace("Unknown", "Unkown") + self.assertIn(text, [expected, macos_bug_expected]) + + exc = ListReadersException(SCARD_S_SUCCESS) + self.assertEqual(exc.hresult, 0) + + exc = ListReadersException(SCARD_E_NO_SERVICE) + self.assertEqual(exc.hresult, SCARD_E_NO_SERVICE) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to list readers: The Smart Card Resource Manager is not running. (0x8010001D)" + else: + expected = "Failed to list readers: Service not available. (0x8010001D)" + self.assertEqual(text, expected) + + def test_EstablishContextException(self): + exc = EstablishContextException(SCARD_E_NO_SERVICE) + self.assertEqual(exc.hresult, SCARD_E_NO_SERVICE) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to establish context: The Smart Card Resource Manager is not running. (0x8010001D)" + else: + expected = "Failed to establish context: Service not available. (0x8010001D)" + self.assertEqual(text, expected) + + def test_IntroduceReaderException(self): + exc = IntroduceReaderException(SCARD_E_DUPLICATE_READER, "foobar") + self.assertEqual(exc.hresult, SCARD_E_DUPLICATE_READER) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to introduce a new reader: foobar: The reader driver did not produce a unique reader name. (0x8010001B)" + else: + expected = "Failed to introduce a new reader: foobar: Reader already exists. (0x8010001B)" + self.assertEqual(text, expected) + + def test_RemoveReaderFromGroupException(self): + exc = RemoveReaderFromGroupException(SCARD_E_INVALID_HANDLE, + "readername", "readergroup") + self.assertEqual(exc.hresult, SCARD_E_INVALID_HANDLE) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to remove reader: readername from group: readergroup: The supplied handle was invalid. (0x80100003)" + else: + expected = "Failed to remove reader: readername from group: readergroup: Invalid handle. (0x80100003)" + self.assertEqual(text, expected) + + def test_AddReaderToGroupException(self): + exc = AddReaderToGroupException(SCARD_E_INVALID_HANDLE, + "reader", "group") + self.assertEqual(exc.hresult, SCARD_E_INVALID_HANDLE) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to add reader: reader to group: group: The supplied handle was invalid. (0x80100003)" + else: + expected = "Failed to add reader: reader to group: group: Invalid handle. (0x80100003)" + self.assertEqual(text, expected) + + def test_ReleaseContextException(self): + exc = ReleaseContextException(SCARD_E_INVALID_HANDLE) + self.assertEqual(exc.hresult, SCARD_E_INVALID_HANDLE) + text = str(exc) + if platform.system() == 'Windows': + expected = "Failed to release context: The supplied handle was invalid. (0x80100003)" + else: + expected = "Failed to release context: Invalid handle. (0x80100003)" + self.assertEqual(text, expected) + + def test_BaseSCardException(self): + exc = BaseSCardException(SCARD_E_UNKNOWN_READER) + self.assertEqual(exc.hresult, SCARD_E_UNKNOWN_READER) + text = str(exc) + if platform.system() == 'Windows': + expected = "scard exception: The specified reader name is not recognized. (0x80100009)" + else: + expected = "scard exception: Unknown reader specified. (0x80100009)" + self.assertEqual(text, expected) + +if __name__ == '__main__': + unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyscard-2.0.2/test/test_SCardGetErrorMessage.py new/pyscard-2.0.5/test/test_SCardGetErrorMessage.py --- old/pyscard-2.0.2/test/test_SCardGetErrorMessage.py 2021-06-11 10:09:41.000000000 +0200 +++ new/pyscard-2.0.5/test/test_SCardGetErrorMessage.py 2022-08-28 18:38:10.000000000 +0200 @@ -7,7 +7,7 @@ import unittest from smartcard.scard import SCardGetErrorMessage from smartcard.scard import SCARD_S_SUCCESS, SCARD_F_INTERNAL_ERROR -from distutils.util import get_platform +import platform class TestError(unittest.TestCase): @@ -17,7 +17,7 @@ # do not test on Windows # the error messages are different and localized - if get_platform() in ('win32', 'win-amd64'): + if platform.system() == 'Windows': return expected = "Command successful."