Hello community,

here is the log from the commit of package python-pyscard for openSUSE:Factory 
checked in at 2019-03-26 15:45:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pyscard (Old)
 and      /work/SRC/openSUSE:Factory/.python-pyscard.new.25356 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pyscard"

Tue Mar 26 15:45:52 2019 rev:6 rq:688650 version:1.9.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pyscard/python-pyscard.changes    
2018-06-29 22:32:04.554224653 +0200
+++ /work/SRC/openSUSE:Factory/.python-pyscard.new.25356/python-pyscard.changes 
2019-03-26 15:45:59.704065239 +0100
@@ -1,0 +2,8 @@
+Mon Mar 25 22:55:08 UTC 2019 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 1.9.8
+  * SmartcardException: store the PC/SC return code in hresult
+  * CardMonitoring: stop the looping only if PCSC exited
+  * Minor documentation improvements
+
+-------------------------------------------------------------------

Old:
----
  pyscard-1.9.7.tar.gz

New:
----
  pyscard-1.9.8.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pyscard.spec ++++++
--- /var/tmp/diff_new_pack.FSW1ut/_old  2019-03-26 15:46:00.628064771 +0100
+++ /var/tmp/diff_new_pack.FSW1ut/_new  2019-03-26 15:46:00.628064771 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pyscard
 #
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
 # Copyright (c) 2011 LISA GmbH, Bingen, Germany.
 #
 # All modifications and additions to the file contributed by third parties
@@ -13,7 +13,7 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
@@ -21,7 +21,7 @@
 %bcond_without test
 %define modname pyscard
 Name:           python-pyscard
-Version:        1.9.7
+Version:        1.9.8
 Release:        0
 Summary:        Python module adding smart card support
 License:        LGPL-2.0-or-later

++++++ pyscard-1.9.7.tar.gz -> pyscard-1.9.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/ChangeLog new/pyscard-1.9.8/ChangeLog
--- old/pyscard-1.9.7/ChangeLog 2018-06-20 17:33:16.000000000 +0200
+++ new/pyscard-1.9.8/ChangeLog 2019-03-25 22:18:55.000000000 +0100
@@ -1,3 +1,11 @@
+1.9.8 (March 2018)
+==================
+    * SmartcardException: store the PC/SC return code in hresult
+    * CardMonitoring: stop the looping only if PCSC exited
+    * setup: support build on OpenBSD, and other BSD
+    * Fix Windows 10 SCARD_E_SERVICE_STOPPED from SCardListReaders()
+    * Minor documentation improvements
+
 1.9.7 (June 2018)
 =================
     * Modify CardMonitoring's deleteObserver method to cleanly remove threads
@@ -5,7 +13,7 @@
     * Python 3: Fix SCardGetErrorMessage() on Windows
     * PCSCPart10: add parseFeatureRequest(), parseTlvProperties()
     * Fix PEP8 warnings
-       * Minor documentation improvements
+    * Minor documentation improvements
 
 1.9.6 (August 2017)
 ===================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/PKG-INFO new/pyscard-1.9.8/PKG-INFO
--- old/pyscard-1.9.7/PKG-INFO  2018-06-20 17:47:46.000000000 +0200
+++ new/pyscard-1.9.8/PKG-INFO  2019-03-25 22:19:53.000000000 +0100
@@ -1,12 +1,12 @@
 Metadata-Version: 2.1
 Name: pyscard
-Version: 1.9.7
+Version: 1.9.8
 Summary: Smartcard module for Python.
 Home-page: https://github.com/LudovicRousseau/pyscard
 Author: Ludovic Rousseau
 Author-email: ludovic.rouss...@free.fr
 License: UNKNOWN
-Download-URL: 
http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.7/pyscard-1.9.7.tar.gz/download
+Download-URL: 
http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.8/pyscard-1.9.8.tar.gz/download
 Description: Smartcard package for Python
 Platform: linux
 Platform: win32
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/pyscard.egg-info/PKG-INFO 
new/pyscard-1.9.8/pyscard.egg-info/PKG-INFO
--- old/pyscard-1.9.7/pyscard.egg-info/PKG-INFO 2018-06-20 17:47:46.000000000 
+0200
+++ new/pyscard-1.9.8/pyscard.egg-info/PKG-INFO 2019-03-25 22:19:52.000000000 
+0100
@@ -1,12 +1,12 @@
 Metadata-Version: 2.1
 Name: pyscard
-Version: 1.9.7
+Version: 1.9.8
 Summary: Smartcard module for Python.
 Home-page: https://github.com/LudovicRousseau/pyscard
 Author: Ludovic Rousseau
 Author-email: ludovic.rouss...@free.fr
 License: UNKNOWN
-Download-URL: 
http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.7/pyscard-1.9.7.tar.gz/download
+Download-URL: 
http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.8/pyscard-1.9.8.tar.gz/download
 Description: Smartcard package for Python
 Platform: linux
 Platform: win32
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/pyscard.egg-info/SOURCES.txt 
new/pyscard-1.9.8/pyscard.egg-info/SOURCES.txt
--- old/pyscard-1.9.7/pyscard.egg-info/SOURCES.txt      2018-06-20 
17:47:46.000000000 +0200
+++ new/pyscard-1.9.8/pyscard.egg-info/SOURCES.txt      2019-03-25 
22:19:52.000000000 +0100
@@ -166,5 +166,6 @@
 smartcard/wx/resources/smartcard.ico
 test/__init__.py
 test/test_ATR.py
+test/test_Exceptions.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-1.9.7/setup.py new/pyscard-1.9.8/setup.py
--- old/pyscard-1.9.7/setup.py  2018-06-20 17:42:52.000000000 +0200
+++ new/pyscard-1.9.8/setup.py  2019-03-25 22:18:55.000000000 +0100
@@ -76,12 +76,12 @@
     platform_swig_opts = ['-DPCSCLITE']
     platform_sources = []
     platform_libraries = []
-    platform_include_dirs = ['/usr/include/PCSC']
+    platform_include_dirs = ['/usr/include/PCSC', '/usr/local/include/PCSC']
     platform_extra_compile_args = []    # ['-ggdb', '-O0']
     platform_extra_link_args = []   # ['-ggdb']
 
 
-VERSION_INFO = (1, 9, 7, 0)
+VERSION_INFO = (1, 9, 8, 0)
 VERSION_STR = '%i.%i.%i' % VERSION_INFO[:3]
 VERSION_ALT = '%i,%01i,%01i,%04i' % VERSION_INFO
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/smartcard/CardMonitoring.py 
new/pyscard-1.9.8/smartcard/CardMonitoring.py
--- old/pyscard-1.9.7/smartcard/CardMonitoring.py       2018-06-20 
17:33:16.000000000 +0200
+++ new/pyscard-1.9.8/smartcard/CardMonitoring.py       2019-03-25 
22:16:58.000000000 +0100
@@ -37,6 +37,8 @@
 from smartcard.Observer import Observable
 
 from smartcard.CardRequest import CardRequest
+from smartcard.Exceptions import SmartcardException
+from smartcard.scard import SCARD_E_NO_SERVICE
 
 _START_ON_DEMAND_ = False
 
@@ -188,14 +190,15 @@
                 except AttributeError:
                     pass
 
-                except:
+                except SmartcardException as exc:
                     # FIXME Tighten the exceptions caught by this block
                     traceback.print_exc()
                     # Most likely raised during interpreter shutdown due
                     # to unclean exit which failed to remove all observers.
                     # To solve this, we set the stop event and pass the
                     # exception to let the thread finish gracefully.
-                    self.stopEvent.set()
+                    if exc.hresult == SCARD_E_NO_SERVICE:
+                        self.stopEvent.set()
 
         # stop the thread by signaling stopEvent
         def stop(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/smartcard/Exceptions.py 
new/pyscard-1.9.8/smartcard/Exceptions.py
--- old/pyscard-1.9.7/smartcard/Exceptions.py   2018-04-18 18:52:31.000000000 
+0200
+++ new/pyscard-1.9.8/smartcard/Exceptions.py   2019-03-25 22:16:58.000000000 
+0100
@@ -24,6 +24,8 @@
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 """
 
+from smartcard.scard import SCardGetErrorMessage
+
 
 class SmartcardException(Exception):
     """Base class for smartcard exceptions.
@@ -32,7 +34,17 @@
     shield scard (i.e. PCSC) exceptions raised by the scard module.
 
     """
-    pass
+    def __init__(self, message="", hresult=-1, *args):
+        super(SmartcardException, self).__init__(message, *args)
+        self.hresult = int(hresult)
+
+    def __str__(self):
+        text = super(SmartcardException, self).__str__()
+        if self.hresult != -1:
+            text += ": %s (0x%08X)" % (SCardGetErrorMessage(self.hresult), 
self.hresult)
+
+        return text
+
 
 
 class CardConnectionException(SmartcardException):
@@ -58,36 +70,39 @@
     pass
 
 
+class CardServiceStoppedException(SmartcardException):
+    """Raised when the CardService was stopped"""
+    pass
+
+
 class InvalidATRMaskLengthException(SmartcardException):
     """Raised when an ATR mask does not match an ATR length."""
 
-    def __init__(self, *args):
-        SmartcardException.__init__(self,
-                                    'Invalid ATR mask length: ', *args)
+    def __init__(self, mask):
+        SmartcardException.__init__(self, 'Invalid ATR mask length: %s'
+            %mask)
 
 
 class InvalidReaderException(SmartcardException):
     """Raised when trying to acces an invalid smartcard reader."""
 
-    def __init__(self, *args):
-        SmartcardException.__init__(self, 'Invalid reader: ', *args)
+    def __init__(self, readername):
+        SmartcardException.__init__(self, 'Invalid reader: %s' % readername)
 
 
 class ListReadersException(SmartcardException):
     """Raised when smartcard readers cannot be listed."""
 
-    def __init__(self, *args):
-        SmartcardException.__init__(self, 'Failed to list readers', *args)
+    def __init__(self, hresult):
+        SmartcardException.__init__(self, 'Failed to list readers',
+                hresult=hresult)
 
 
 class NoCardException(SmartcardException):
     """Raised when no card in is present in reader."""
 
-    def __init__(self, *args):
-        SmartcardException.__init__(
-            self,
-            'Unable to connect to card or no card in reader',
-            *args)
+    def __init__(self, message, hresult):
+        SmartcardException.__init__(self, message, hresult=hresult)
 
 
 class NoReadersException(SmartcardException):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/smartcard/pcsc/PCSCCardConnection.py 
new/pyscard-1.9.8/smartcard/pcsc/PCSCCardConnection.py
--- old/pyscard-1.9.7/smartcard/pcsc/PCSCCardConnection.py      2016-09-11 
18:31:53.000000000 +0200
+++ new/pyscard-1.9.8/smartcard/pcsc/PCSCCardConnection.py      2019-03-25 
22:16:58.000000000 +0100
@@ -118,9 +118,7 @@
         if hresult != 0:
             self.hcard = None
             if hresult in (SCARD_W_REMOVED_CARD, SCARD_E_NO_SMARTCARD):
-                raise NoCardException(
-                    'Unable to connect: ' + \
-                    SCardGetErrorMessage(hresult))
+                raise NoCardException('Unable to connect', hresult=hresult)
             else:
                 raise CardConnectionException(
                     'Unable to connect with protocol: ' + \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/smartcard/pcsc/PCSCContext.py 
new/pyscard-1.9.8/smartcard/pcsc/PCSCContext.py
--- old/pyscard-1.9.7/smartcard/pcsc/PCSCContext.py     2015-06-17 
21:34:44.000000000 +0200
+++ new/pyscard-1.9.8/smartcard/pcsc/PCSCContext.py     2019-03-25 
22:16:58.000000000 +0100
@@ -42,6 +42,9 @@
         def getContext(self):
             return self.hcontext
 
+        def releaseContext(self):
+            return SCardReleaseContext(self.hcontext)
+
     # the singleton
     mutex = RLock()
     instance = None
@@ -50,10 +53,23 @@
         PCSCContext.mutex.acquire()
         try:
             if not PCSCContext.instance:
-                PCSCContext.instance = PCSCContext.__PCSCContextSingleton()
+                self.renewContext()
         finally:
             PCSCContext.mutex.release()
 
     def __getattr__(self, name):
         if self.instance:
             return getattr(self.instance, name)
+
+    def renewContext():
+        PCSCContext.mutex.acquire()
+        try:
+            if PCSCContext.instance is not None:
+                PCSCContext.instance.releaseContext()
+
+            PCSCContext.instance = PCSCContext.__PCSCContextSingleton()
+        finally:
+            PCSCContext.mutex.release()
+
+        return PCSCContext.instance.getContext()
+    renewContext = staticmethod(renewContext)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/smartcard/pcsc/PCSCReader.py 
new/pyscard-1.9.8/smartcard/pcsc/PCSCReader.py
--- old/pyscard-1.9.7/smartcard/pcsc/PCSCReader.py      2016-09-10 
18:07:13.000000000 +0200
+++ new/pyscard-1.9.8/smartcard/pcsc/PCSCReader.py      2019-03-25 
22:16:58.000000000 +0100
@@ -45,6 +45,8 @@
     if hresult != 0:
         if hresult == SCARD_E_NO_READERS_AVAILABLE:
             readers = []
+        elif hresult == SCARD_E_SERVICE_STOPPED:
+            raise CardServiceStoppedException()
         else:
             raise ListReadersException(hresult)
 
@@ -107,7 +109,13 @@
         creaders = []
         hcontext = PCSCContext().getContext()
 
-        for reader in __PCSCreaders__(hcontext, groups):
+        try:
+            pcsc_readers = __PCSCreaders__(hcontext, groups)
+        except CardServiceStoppedException:
+            hcontext = PCSCContext.renewContext()
+            pcsc_readers = __PCSCreaders__(hcontext, groups)
+
+        for reader in pcsc_readers:
             creaders.append(PCSCReader.Factory.create(reader))
         return creaders
     readers = staticmethod(readers)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/test/test_Exceptions.py 
new/pyscard-1.9.8/test/test_Exceptions.py
--- old/pyscard-1.9.7/test/test_Exceptions.py   1970-01-01 01:00:00.000000000 
+0100
+++ new/pyscard-1.9.8/test/test_Exceptions.py   2019-03-25 22:16:58.000000000 
+0100
@@ -0,0 +1,63 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# to execute:
+# $ cd test
+# $ python -m unittest
+
+import unittest
+from smartcard.Exceptions import *
+from smartcard.scard import *
+from distutils.util import get_platform
+
+
+class TestUtil(unittest.TestCase):
+
+    def test_Exceptions(self):
+        exc = SmartcardException()
+        self.assertEqual(exc.hresult, -1)
+
+
+    def test_ListReadersException(self):
+        exc = ListReadersException(0)
+        self.assertEqual(exc.hresult, 0)
+        text = str(exc)
+        if not get_platform().startswith('win'):
+            self.assertEqual(text, "Failed to list readers: Command 
successful. (0x00000000)")
+
+        exc = ListReadersException(0x42)
+        self.assertEqual(exc.hresult, 0x42)
+        text = str(exc)
+        if get_platform().startswith('linux'):
+            self.assertEqual(text, "Failed to list readers: Unknown error: 
0x00000042 (0x00000042)")
+
+        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 get_platform().startswith('linux'):
+            self.assertEqual(text, "Failed to list readers: Service not 
available. (0x8010001D)")
+
+    def test_NoReadersException(self):
+        exc = NoReadersException()
+        self.assertEqual(exc.hresult, -1)
+        text = str(exc)
+        self.assertEqual(text, "No reader found")
+
+    def test_InvalidReaderException(self):
+        exc = InvalidReaderException("foobar")
+        self.assertEqual(exc.hresult, -1)
+        text = str(exc)
+        self.assertEqual(text, "Invalid reader: foobar")
+
+    def test_CardConnectionException(self):
+        exc= CardConnectionException()
+        self.assertEqual(exc.hresult, -1)
+        text = str(exc)
+        self.assertEqual(text, "")
+
+
+if __name__ == '__main__':
+    unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyscard-1.9.7/test/test_SCardGetErrorMessage.py 
new/pyscard-1.9.8/test/test_SCardGetErrorMessage.py
--- old/pyscard-1.9.7/test/test_SCardGetErrorMessage.py 2018-06-20 
17:33:16.000000000 +0200
+++ new/pyscard-1.9.8/test/test_SCardGetErrorMessage.py 2019-03-25 
22:16:58.000000000 +0100
@@ -30,7 +30,7 @@
 
         res = SCardGetErrorMessage(1)
         # macOS bug not yet fixed
-        if get_platform().startswith('macosx-'):
+        if get_platform().startswith('macosx-') and get_platform() < 
'macosx-10.13':
             expected = "Unkown error: 0x00000001"
         else:
             expected = "Unknown error: 0x00000001"


Reply via email to