[Python-modules-commits] [pyscard] 01/03: New upstream version 1.9.5

Ludovic Rousseau rousseau at moszumanska.debian.org
Fri Feb 17 15:21:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository pyscard.

commit 6670ed9a51025225d28676ce3a8dd219e903c809
Author: Ludovic Rousseau <rousseau at debian.org>
Date:   Fri Feb 17 15:01:55 2017 +0100

    New upstream version 1.9.5
---
 ChangeLog                                 |   6 +
 PKG-INFO                                  |   6 +-
 pyscard.egg-info/PKG-INFO                 |   6 +-
 setup.cfg                                 |   1 -
 setup.py                                  |   4 +-
 smartcard/ATR.py                          |  31 ++---
 smartcard/AbstractCardRequest.py          |  14 +--
 smartcard/CardConnection.py               |  30 ++---
 smartcard/CardConnectionEvent.py          |  14 +--
 smartcard/CardMonitoring.py               |  16 +--
 smartcard/CardRequest.py                  |  14 +--
 smartcard/CardType.py                     |  22 ++--
 smartcard/Observer.py                     |   3 +-
 smartcard/ReaderMonitoring.py             |   8 +-
 smartcard/Session.py                      |   8 +-
 smartcard/pcsc/PCSCCardConnection.py      |  10 +-
 smartcard/scard/helpers.c                 | 196 +++++++++++++++---------------
 smartcard/scard/scard.i                   |  15 +--
 smartcard/sw/ISO7816_4ErrorChecker.py     |  38 +++---
 smartcard/sw/ISO7816_4_SW1ErrorChecker.py |  30 ++---
 smartcard/sw/ISO7816_8ErrorChecker.py     |  28 ++---
 smartcard/sw/ISO7816_9ErrorChecker.py     |  22 ++--
 smartcard/sw/op21_ErrorChecker.py         |  34 +++---
 smartcard/util/__init__.py                |  38 +++---
 smartcard/wx/APDUHexValidator.py          |   3 +-
 smartcard/wx/CardAndReaderTreePanel.py    |  12 +-
 smartcard/wx/SimpleSCardApp.py            |  30 ++---
 smartcard/wx/SimpleSCardAppFrame.py       |  53 ++++----
 28 files changed, 351 insertions(+), 341 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ce3b87b..0fbe1de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1.9.5 (Feb 2017)
+================
+    * SCardGetStatusChange(): fix a memory leak with Python 3
+    * SCardTransmit(): use SCARD_PCI_RAW for undefined protocol
+    * Improve epydoc documentation
+
 1.9.4 (May 2016)
 ================
     * Fix installation using pip and easy_install
diff --git a/PKG-INFO b/PKG-INFO
index a0946d4..d7e35dc 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: pyscard
-Version: 1.9.4
+Version: 1.9.5
 Summary: Smartcard module for Python.
 Home-page: http://www.gemalto.com
 Author: Jean-Daniel Aussel
 Author-email: aussel.jean-daniel at gemalto.com
 License: GNU LESSER GENERAL PUBLIC LICENSE
-Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.4/pyscard-1.9.4.tar.gz/download
+Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.5/pyscard-1.9.5.tar.gz/download
 Description: Smartcard package for Python
 Platform: linux
 Platform: win32
@@ -20,4 +20,4 @@ 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: Topic :: Security 
+Classifier: Topic :: Security
diff --git a/pyscard.egg-info/PKG-INFO b/pyscard.egg-info/PKG-INFO
index a0946d4..d7e35dc 100644
--- a/pyscard.egg-info/PKG-INFO
+++ b/pyscard.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: pyscard
-Version: 1.9.4
+Version: 1.9.5
 Summary: Smartcard module for Python.
 Home-page: http://www.gemalto.com
 Author: Jean-Daniel Aussel
 Author-email: aussel.jean-daniel at gemalto.com
 License: GNU LESSER GENERAL PUBLIC LICENSE
-Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.4/pyscard-1.9.4.tar.gz/download
+Download-URL: http://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.5/pyscard-1.9.5.tar.gz/download
 Description: Smartcard package for Python
 Platform: linux
 Platform: win32
@@ -20,4 +20,4 @@ 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: Topic :: Security 
+Classifier: Topic :: Security
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8bfd5a1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index 6e4a4e0..ae1f8c3 100755
--- a/setup.py
+++ b/setup.py
@@ -79,7 +79,7 @@ else:
     platform_extra_link_args = []   # ['-ggdb']
 
 
-VERSION_INFO = (1, 9, 4, 0)
+VERSION_INFO = (1, 9, 5, 0)
 VERSION_STR = '%i.%i.%i' % VERSION_INFO[:3]
 VERSION_ALT = '%i,%01i,%01i,%04i' % VERSION_INFO
 
@@ -153,7 +153,7 @@ kw = {'name': "pyscard",
           'Programming Language :: Python :: 2.7',
           'Programming Language :: Python :: 3.3',
           'Programming Language :: Python :: 3.4',
-          'Topic :: Security ',
+          'Topic :: Security',
           ]
      }
 
diff --git a/smartcard/ATR.py b/smartcard/ATR.py
index 8c55d6e..b7a3dfc 100644
--- a/smartcard/ATR.py
+++ b/smartcard/ATR.py
@@ -48,20 +48,23 @@ class ATR(object):
             raise SmartcardException("invalid TS 0x%-0.2x" % self.bytes[0])
 
     def __initInstance__(self):
-        """Parse ATR and initialize members:
-            TS: initial character
-            T0: format character
-            TA[n], TB[n], TC[n], TD[n], for n=0,1,...: protocol parameters
-                note: protocol parameters indices start at 0, e.g.
-                TA[0], TA[1] correspond to the ISO standard TA1, TA2
-                parameters
-            historicalBytes: the ATR T1, T2, ..., TK historical bytes
-            TCK: checksum byte (only for protocols different from T=0)
-            FI: clock rate conversion factor
-            DI: voltage adjustment factor
-            PI1: programming voltage factor
-            II: maximum programming current factor
-            N: extra guard time
+        """
+        Parse ATR and initialize members:
+          - TS: initial character
+          - T0: format character
+          - TA[n], TB[n], TC[n], TD[n], for n=0,1,...: protocol parameters
+
+        @note: protocol parameters indices start at 0, e.g.
+        TA[0], TA[1] correspond to the ISO standard TA1, TA2
+        parameters
+
+          - historicalBytes: the ATR T1, T2, ..., TK historical bytes
+          - TCK: checksum byte (only for protocols different from T=0)
+          - FI: clock rate conversion factor
+          - DI: voltage adjustment factor
+          - PI1: programming voltage factor
+          - II: maximum programming current factor
+          - N: extra guard time
         """
         self.__checksyncbyte__()
 
diff --git a/smartcard/AbstractCardRequest.py b/smartcard/AbstractCardRequest.py
index ef3206f..43b559c 100644
--- a/smartcard/AbstractCardRequest.py
+++ b/smartcard/AbstractCardRequest.py
@@ -39,22 +39,22 @@ class AbstractCardRequest(object):
                  cardType=None, cardServiceClass=None, timeout=1):
         """Construct new CardRequest.
 
-        newcardonly:        if True, request a new card; default is
+        @param newcardonly: if True, request a new card; default is
                             False, i.e. accepts cards already inserted
 
-        readers:            the list of readers to consider for
+        @param readers:     the list of readers to consider for
                             requesting a card; default is to consider
                             all readers
 
-        cardType:           the smartcard.CardType.CardType to wait for;
-                            default is smartcard.CardType.AnyCardType,
+        @param cardType:    the L{smartcard.CardType.CardType} to wait for;
+                            default is L{smartcard.CardType.AnyCardType},
                             i.e. the request will succeed with any card
 
-        cardServiceClass:   the specific card service class to create
+        @param cardServiceClass: the specific card service class to create
                             and bind to the card;default is to create
-                            and bind a smartcard.PassThruCardService
+                            and bind a L{smartcard.PassThruCardService}
 
-        timeout:            the time in seconds we are ready to wait for
+        @param timeout:     the time in seconds we are ready to wait for
                             connecting to the requested card.  default
                             is to wait one second; to wait forever, set
                             timeout to None
diff --git a/smartcard/CardConnection.py b/smartcard/CardConnection.py
index 6ceea1b..8bd7da7 100644
--- a/smartcard/CardConnection.py
+++ b/smartcard/CardConnection.py
@@ -40,7 +40,7 @@ class CardConnection(Observable):
     def __init__(self, reader):
         """Construct a new card connection.
 
-        readerName: name of the reader in which the smartcard to connect
+        @param reader: name of the reader in which the smartcard to connect
         to is located.
         """
         Observable.__init__(self)
@@ -56,8 +56,8 @@ class CardConnection(Observable):
     def addSWExceptionToFilter(self, exClass):
         """Add a status word exception class to be filtered.
 
-        exClass: the class to filter, e.g.
-        smartcard.sw.SWException.WarningProcessingException
+        @param exClass: the class to filter, e.g.
+        L{smartcard.sw.SWException.WarningProcessingException}
 
         Filtered exceptions will not be raised when encountered in the
         error checking chain."""
@@ -74,14 +74,14 @@ class CardConnection(Observable):
 
     def connect(self, protocol=None, mode=None, disposition=None):
         """Connect to card.
-        protocol: a bit mask of the protocols to use, from
-        CardConnection.T0_protocol, CardConnection.T1_protocol,
-        CardConnection.RAW_protocol, CardConnection.T15_protocol
+        @param protocol: a bit mask of the protocols to use, from
+        L{CardConnection.T0_protocol}, L{CardConnection.T1_protocol},
+        L{CardConnection.RAW_protocol}, L{CardConnection.T15_protocol}
 
-        mode: SCARD_SHARE_SHARED (default), SCARD_SHARE_EXCLUSIVE or
+        @param mode: SCARD_SHARE_SHARED (default), SCARD_SHARE_EXCLUSIVE or
         SCARD_SHARE_DIRECT
 
-        disposition: SCARD_LEAVE_CARD (default), SCARD_RESET_CARD,
+        @param disposition: SCARD_LEAVE_CARD (default), SCARD_RESET_CARD,
         SCARD_UNPOWER_CARD or SCARD_EJECT_CARD
         """
         Observable.setChanged(self)
@@ -110,7 +110,7 @@ class CardConnection(Observable):
 
     def setErrorCheckingChain(self, errorcheckingchain):
         """Add an error checking chain.
-        errorcheckingchain: a smartcard.sw.ErrorCheckingChain object The
+        @param errorcheckingchain: a smartcard.sw.ErrorCheckingChain object The
         error checking strategies in errorchecking chain will be tested
         with each received response APDU, and a
         smartcard.sw.SWException.SWException will be raised upon
@@ -119,7 +119,7 @@ class CardConnection(Observable):
 
     def setProtocol(self, protocol):
         """Set protocol for card connection.
-        protocol: a bit mask of CardConnection.T0_protocol,
+        @param protocol: a bit mask of CardConnection.T0_protocol,
         CardConnection.T1_protocol, CardConnection.RAW_protocol,
         CardConnection.T15_protocol e.g.
         setProtocol(CardConnection.T1_protocol |
@@ -131,9 +131,9 @@ class CardConnection(Observable):
         and notify observers upon command/response APDU events.
         Subclasses must override the doTransmit() class method.
 
-        bytes:      list of bytes to transmit
+        @param bytes:      list of bytes to transmit
 
-        protocol:   the transmission protocol, from
+        @param protocol:   the transmission protocol, from
                     CardConnection.T0_protocol,
                     CardConnection.T1_protocol, or
                     CardConnection.RAW_protocol
@@ -165,9 +165,9 @@ class CardConnection(Observable):
         class method and notify observers upon command/response events.
         Subclasses must override the doControl() class method.
 
-        controlCode: command code
+        @param controlCode: command code
 
-        bytes:       list of bytes to transmit
+        @param bytes:       list of bytes to transmit
         """
         Observable.setChanged(self)
         Observable.notifyObservers(self,
@@ -193,7 +193,7 @@ class CardConnection(Observable):
     def getAttrib(self, attribId):
         """return the requested attribute
 
-        attribId: attribute id like SCARD_ATTR_VENDOR_NAME
+        @param attribId: attribute id like SCARD_ATTR_VENDOR_NAME
         """
         Observable.setChanged(self)
         Observable.notifyObservers(self,
diff --git a/smartcard/CardConnectionEvent.py b/smartcard/CardConnectionEvent.py
index b9709f3..458ad46 100644
--- a/smartcard/CardConnectionEvent.py
+++ b/smartcard/CardConnectionEvent.py
@@ -27,14 +27,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 class CardConnectionEvent(object):
     """Base class for card connection events.
 
-    This event is notified by CardConnection objects.
-
-    type:   'connect', 'disconnect', 'command', 'response'
-    args:   None for 'connect' or 'disconnect'
-            command APDU byte list for 'command'
-            [response data, sw1, sw2] for 'response'
-    type:   'connect'   args:"""
+    This event is notified by CardConnection objects."""
 
     def __init__(self, type, args=None):
+        """
+        @param type:   'connect', 'disconnect', 'command', 'response'
+        @param args:   None for 'connect' or 'disconnect'
+                command APDU byte list for 'command'
+                [response data, sw1, sw2] for 'response'
+        """
         self.type = type
         self.args = args
diff --git a/smartcard/CardMonitoring.py b/smartcard/CardMonitoring.py
index 6265eb5..ebd4192 100644
--- a/smartcard/CardMonitoring.py
+++ b/smartcard/CardMonitoring.py
@@ -45,25 +45,25 @@ _START_ON_DEMAND_ = False
 class CardObserver(Observer):
     """
     CardObserver is a base abstract class for objects that are to be notified
-    upon smartcard reader insertion/removal.
+    upon smart card insertion / removal.
     """
 
     def __init__(self):
         pass
 
     def update(self, observable, handlers):
-        """Called upon reader insertion/removal.
+        """Called upon smart card insertion / removal.
 
-        observable:
-        handlers:
-            addedcards: list of added readers causing notification
-            removedcards: list of removed readers causing notification
+        @param observable:
+        @param handlers:
+          - addedcards: list of inserted smart cards causing notification
+          - removedcards: list of removed smart cards causing notification
         """
         pass
 
 
 class CardMonitor(object):
-    """Class that monitors smart card insertion/removal.
+    """Class that monitors smart card insertion / removals.
     and notify observers
 
     note: a card monitoring thread will be running
@@ -77,7 +77,7 @@ class CardMonitor(object):
     """
 
     class __CardMonitorSingleton(Observable):
-        """The real smartcard monitor class.
+        """The real smart card monitor class.
 
         A single instance of this class is created
         by the public CardMonitor class.
diff --git a/smartcard/CardRequest.py b/smartcard/CardRequest.py
index bb07fbb..ee405f0 100644
--- a/smartcard/CardRequest.py
+++ b/smartcard/CardRequest.py
@@ -35,23 +35,23 @@ class CardRequest(object):
         cardServiceClass=None, timeout=1):
         """Construct new CardRequest.
 
-        newcardonly:        if True, request a new card
+        @param newcardonly: if True, request a new card
                             default is False, i.e. accepts cards already
                             inserted
 
-        readers:            the list of readers to consider for
+        @param readers:     the list of readers to consider for
                             requesting a card default is to consider all
                             readers
 
-        cardType:           the smartcard.CardType.CardType to wait for;
-                            default is smartcard.CardType.AnyCardType,
+        @param cardType:    the L{smartcard.CardType.CardType} to wait for;
+                            default is L{smartcard.CardType.AnyCardType},
                             i.e. the request will succeed with any card
 
-        cardServiceClass:   the specific card service class to create
+        @param cardServiceClass: the specific card service class to create
                             and bind to the card default is to create
-                            and bind a smartcard.PassThruCardService
+                            and bind a L{smartcard.PassThruCardService}
 
-        timeout:            the time in seconds we are ready to wait for
+        @param timeout:     the time in seconds we are ready to wait for
                             connecting to the requested card.  default
                             is to wait one second to wait forever, set
                             timeout to None
diff --git a/smartcard/CardType.py b/smartcard/CardType.py
index a9d6cdf..e56a4fa 100644
--- a/smartcard/CardType.py
+++ b/smartcard/CardType.py
@@ -30,8 +30,8 @@ from smartcard.util import toHexString
 class CardType(object):
     """Abstract base class for CardTypes.
 
-    Known sub-classes: smartcard.CardType.AnyCardType
-                       smartcard.CardType.ATRCardType."""
+    Known sub-classes: L{smartcard.CardType.AnyCardType}
+    L{smartcard.CardType.ATRCardType}."""
 
     def __init__(self):
         """CardType constructor."""
@@ -40,8 +40,8 @@ class CardType(object):
     def matches(self, atr, reader=None):
         """Returns true if atr and card connected match the CardType.
 
-        atr:    the atr to chek for matching
-        reader: the reader (optional); default is None
+        @param atr:    the atr to chek for matching
+        @param reader: the reader (optional); default is None
 
         The reader can be use in some sub-classes to do advanced
         matching that require connecting to the card."""
@@ -54,8 +54,8 @@ class AnyCardType(CardType):
     def matches(self, atr, reader=None):
         """Always returns true, i.e. AnyCardType matches any card.
 
-        atr:    the atr to chek for matching
-        reader: the reader (optional); default is None"""
+        @param atr:    the atr to chek for matching
+        @param reader: the reader (optional); default is None"""
         return True
 
 
@@ -64,9 +64,9 @@ class ATRCardType(CardType):
 
     def __init__(self, atr, mask=None):
         """ATRCardType constructor.
-        atr:    the ATR of the CardType
-        mask:   an optional mask to be applied to the ATR for CardType matching
-                default is None
+        @param atr:    the ATR of the CardType
+        @param mask:   an optional mask to be applied to the ATR for
+            L{CardType} matching default is None
         """
         self.atr = list(atr)
         self.mask = mask
@@ -80,8 +80,8 @@ class ATRCardType(CardType):
     def matches(self, atr, reader=None):
         """Returns true if the atr matches the masked CardType atr.
 
-        atr:    the atr to chek for matching
-        reader: the reader (optional); default is None
+        @param atr:    the atr to chek for matching
+        @param reader: the reader (optional); default is None
 
         When atr is compared to the CardType ATR, matches returns true if
         and only if CardType.atr & CardType.mask = atr & CardType.mask,
diff --git a/smartcard/Observer.py b/smartcard/Observer.py
index b5f2b4c..aee76ac 100644
--- a/smartcard/Observer.py
+++ b/smartcard/Observer.py
@@ -9,8 +9,7 @@ Class support for "observer" pattern.
 The observer class is the base class
 for all smartcard package observers.
 
-Known subclasses:
-        smartcard.ReaderObserver
+Known subclasses: L{smartcard.ReaderObserver}
 
 """
 
diff --git a/smartcard/ReaderMonitoring.py b/smartcard/ReaderMonitoring.py
index ac3f5ba..fde4cbf 100644
--- a/smartcard/ReaderMonitoring.py
+++ b/smartcard/ReaderMonitoring.py
@@ -52,10 +52,10 @@ class ReaderObserver(Observer):
     def update(self, observable, handlers):
         """Called upon reader insertion/removal.
 
-        observable:
-        handlers:
-            addedreaders: list of added readers causing notification
-            removedreaders: list of removed readers causing notification
+        @param observable:
+        @param handlers:
+          - addedreaders: list of added readers causing notification
+          - removedreaders: list of removed readers causing notification
         """
         pass
 
diff --git a/smartcard/Session.py b/smartcard/Session.py
index 940b10c..88e6509 100644
--- a/smartcard/Session.py
+++ b/smartcard/Session.py
@@ -49,8 +49,8 @@ class Session(object):
         """Session constructor. Initializes a smart card session and
         connect to the card.
 
-        readerName:         reader to connect to; default is first PCSC reader
-        cardServiceClass:   card service to bind the session to; default
+        @param readerName: reader to connect to; default is first PCSC reader
+        @param cardServiceClass: card service to bind the session to; default
                             is None
         """
 
@@ -89,9 +89,9 @@ class Session(object):
     def sendCommandAPDU(self, command):
         """Send an APDU command to the connected smartcard.
 
-        command:    list of APDU bytes, e.g. [0xA0, 0xA4, 0x00, 0x00, 0x02]
+        @param command: list of APDU bytes, e.g. [0xA0, 0xA4, 0x00, 0x00, 0x02]
 
-        returns a tuple (response, sw1, sw2) where
+        @return: a tuple (response, sw1, sw2) where
                 response is the APDU response
                 sw1, sw2 are the two status words
         """
diff --git a/smartcard/pcsc/PCSCCardConnection.py b/smartcard/pcsc/PCSCCardConnection.py
index 7eb2a48..6c8fcb1 100644
--- a/smartcard/pcsc/PCSCCardConnection.py
+++ b/smartcard/pcsc/PCSCCardConnection.py
@@ -173,13 +173,13 @@ class PCSCCardConnection(CardConnection):
     def doTransmit(self, bytes, protocol=None):
         """Transmit an apdu to the card and return response apdu.
 
-        bytes:      command apdu to transmit (list of bytes)
+        @param bytes:    command apdu to transmit (list of bytes)
 
-        protocol:   the transmission protocol, from CardConnection.T0_protocol,
-                    CardConnection.T1_protocol,
-                    or CardConnection.RAW_protocol
+        @param protocol: the transmission protocol, from
+            CardConnection.T0_protocol, CardConnection.T1_protocol, or
+            CardConnection.RAW_protocol
 
-        return:     a tuple (response, sw1, sw2) where
+        @return:     a tuple (response, sw1, sw2) where
                     sw1 is status word 1, e.g. 0x90
                     sw2 is status word 2, e.g. 0x1A
                     response are the response bytes excluding status words
diff --git a/smartcard/scard/helpers.c b/smartcard/scard/helpers.c
index a494b31..2b199e0 100644
--- a/smartcard/scard/helpers.c
+++ b/smartcard/scard/helpers.c
@@ -1,4 +1,4 @@
-/*==============================================================================
+/*===========================================================================
 Copyright 2001-2012 gemalto
 Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel at gemalto.com
 
@@ -17,7 +17,7 @@ GNU Lesser General Public License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with pyscard; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-==============================================================================*/
+===========================================================================*/
 #ifdef WIN32
     #include <windows.h>
 #endif
@@ -55,10 +55,10 @@ extern PyObject* PyExc_SCardError;
 #endif
 
 
-/**==========================================================================**/
+/**=======================================================================**/
 static int _IsAReaderState( PyObject* o)
-/*==============================================================================
-==============================================================================*/
+/*===========================================================================
+===========================================================================*/
 {
     PyObject* o2;
 
@@ -93,10 +93,10 @@ static int _IsAReaderState( PyObject* o)
     return 1;
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 static int _ReaderStateFromTuple( PyObject* o, READERSTATELIST* prl, unsigned int x )
-/*==============================================================================
-==============================================================================*/
+/*===========================================================================
+===========================================================================*/
 {
     char* psz;
     PyObject* o2;
@@ -115,8 +115,6 @@ static int _ReaderStateFromTuple( PyObject* o, READERSTATELIST* prl, unsigned in
         psz = PyBytes_AsString(temp_bytes); // Borrowed pointer
         if (NULL == psz)
             return 0;
-        psz = strdup(psz);
-        Py_DECREF(temp_bytes);
     }
     else
         return 0;
@@ -133,6 +131,10 @@ static int _ReaderStateFromTuple( PyObject* o, READERSTATELIST* prl, unsigned in
     prl->ars[x].szReader = prl->aszReaderNames[x];
     strcpy( prl->aszReaderNames[x], psz );
 
+#if PY_MAJOR_VERSION >= 3
+    Py_DECREF(temp_bytes);
+#endif
+
     // second tuple item is current state
     o2=PyTuple_GetItem(o, 1);
     prl->ars[x].dwCurrentState = (SCARDDWORDARG)PyInt_AsLong(o2);
@@ -157,16 +159,16 @@ static int _ReaderStateFromTuple( PyObject* o, READERSTATELIST* prl, unsigned in
 }
 
 
-/**=============================================================================
+/**==========================================================================
                             BYTELIST Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendByteListToPyObject(
     BYTELIST* source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 builds a Python list from a byte list
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* oByteList;
 
@@ -213,11 +215,11 @@ builds a Python list from a byte list
 }
 
 
-/**==========================================================================**/
+/**=======================================================================**/
 BYTELIST* SCardHelper_PyByteListToBYTELIST(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a Python byte list from a BYTELIST
-==============================================================================*/
+===========================================================================*/
 {
     Py_ssize_t cBytes, x;
     BYTELIST* pbl;
@@ -275,11 +277,11 @@ build a Python byte list from a BYTELIST
     return (BYTELIST*)pbl;
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_PrintByteList( BYTELIST* apsz )
-/*==============================================================================
+/*===========================================================================
 dump a byte list
-==============================================================================*/
+===========================================================================*/
 {
     unsigned long i;
 
@@ -291,16 +293,16 @@ dump a byte list
 }
 
 
-/**=============================================================================
+/**==========================================================================
                             ERRORSTRING Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_OutErrorStringAsPyObject(
     ERRORSTRING* source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 Builds a Python string from an ERRORSTRING
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* pystr;
 
@@ -316,16 +318,16 @@ Builds a Python string from an ERRORSTRING
     }
 }
 
-/**=============================================================================
+/**==========================================================================
                             GUIDLIST Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendGuidListToPyObject(
     GUIDLIST* source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 build a Python GUID list from a C GUID list
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* oByte;
     PyObject* oGuildItem;
@@ -401,11 +403,11 @@ build a Python GUID list from a C GUID list
 
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 GUIDLIST* SCardHelper_PyGuidListToGUIDLIST(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a Python byte list from a GUIDLIST
-==============================================================================*/
+===========================================================================*/
 {
     Py_ssize_t cBytes, cGuids, x;
     //int iGuid, iByte;
@@ -497,11 +499,11 @@ build a Python byte list from a GUIDLIST
     return (GUIDLIST*)pgl;
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_PrintGuidList( GUIDLIST* apsz )
-/*==============================================================================
+/*===========================================================================
 dump a GUID list
-==============================================================================*/
+===========================================================================*/
 {
     unsigned long i, j;
 
@@ -517,15 +519,15 @@ dump a GUID list
 }
 
 
-/**=============================================================================
+/**==========================================================================
                             READERSTATELIST Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendReaderStateListToPyObject(
     READERSTATELIST* source, PyObject** ptarget )
-/*==============================================================================
-==============================================================================*/
+/*===========================================================================
+===========================================================================*/
 {
     PyObject* oRStateList;
     //PyObject* o;
@@ -594,11 +596,11 @@ void SCardHelper_AppendReaderStateListToPyObject(
     }
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 READERSTATELIST* SCardHelper_PyReaderStateListToREADERSTATELIST(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a READERSTATELIST from a Python list of reader states
-==============================================================================*/
+===========================================================================*/
 {
     SCARDDWORDARG cRStates, x;
     READERSTATELIST* prl;
@@ -675,11 +677,11 @@ build a READERSTATELIST from a Python list of reader states
     return (READERSTATELIST*)prl;
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_PrintReaderStateList( READERSTATELIST* prl )
-/*==============================================================================
+/*===========================================================================
 dump a reader state list
-==============================================================================*/
+===========================================================================*/
 {
     int i;
     SCARDDWORDARG j;
@@ -744,16 +746,16 @@ dump a reader state list
     }
 }
 
-/**=============================================================================
+/**==========================================================================
                             SCARDCONTEXT Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendSCardContextToPyObject(
     SCARDCONTEXT source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 builds a Python SCARDCONTEXT from a C SCARDCONTEXT
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* oScardContext;
 
@@ -788,11 +790,11 @@ builds a Python SCARDCONTEXT from a C SCARDCONTEXT
     }
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 SCARDCONTEXT SCardHelper_PyScardContextToSCARDCONTEXT(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a SCARDCONTEXT from a python SCARDCONTEXT
-==============================================================================*/
+===========================================================================*/
 {
     SCARDCONTEXT scRet=0;
 
@@ -814,16 +816,16 @@ build a SCARDCONTEXT from a python SCARDCONTEXT
 }
 
 
-/**=============================================================================
+/**==========================================================================
                             SCARDHANDLE Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendSCardHandleToPyObject(
     SCARDHANDLE source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 builds a Python SCARDHANDLE from a C SCARDHANDLE
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* oScardHandle;
 
@@ -858,11 +860,11 @@ builds a Python SCARDHANDLE from a C SCARDHANDLE
     }
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 SCARDCONTEXT SCardHelper_PyScardHandleToSCARDHANDLE(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a SCARDHANDLE from a python SCARDHANDLE
-==============================================================================*/
+===========================================================================*/
 {
     SCARDHANDLE scRet=0;
 
@@ -883,16 +885,16 @@ build a SCARDHANDLE from a python SCARDHANDLE
     return scRet;
 }
 
-/**=============================================================================
+/**==========================================================================
                             SCARDDWORDARG Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendSCardDwordArgToPyObject(
     SCARDDWORDARG source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 builds a Python SCARDDWORDARG from a C SCARDDWORDARG
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* oScardDword;
 
@@ -927,11 +929,11 @@ builds a Python SCARDDWORDARG from a C SCARDDWORDARG
     }
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 SCARDDWORDARG SCardHelper_PySCardDwordArgToSCARDDWORDARG(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a SCARDDWORDARG from a python SCARDDWORDARG
-==============================================================================*/
+===========================================================================*/
 {
     SCARDDWORDARG scRet=0;
 
@@ -953,16 +955,16 @@ build a SCARDDWORDARG from a python SCARDDWORDARG
 }
 
 
-/**=============================================================================
+/**==========================================================================
                             STRING Helpers
-==============================================================================*/
+===========================================================================*/
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendStringToPyObject(
     STRING* source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 Builds a Python string from a STRING
-==============================================================================*/
+===========================================================================*/
 {
     PyObject* pystr;
 
@@ -1010,12 +1012,12 @@ Builds a Python string from a STRING
     }
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 STRING* SCardHelper_PyStringToString( PyObject* source )
-/*==============================================================================
+/*===========================================================================
 Build a STRING from a Python string; the string is allocated and
 will have to be freed externally to the wrapper
-==============================================================================*/
+===========================================================================*/
 {
     size_t ulLength;
     STRING* pstr=NULL;
@@ -1051,11 +1053,11 @@ will have to be freed externally to the wrapper
     return pstr;
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_PrintString( STRING* str )
-/*==============================================================================
+/*===========================================================================
 dump a string list
-==============================================================================*/
+===========================================================================*/
 {
     if(NULL!=str)
     {
@@ -1067,19 +1069,19 @@ dump a string list
     }
 }
 
-/**=============================================================================
+/**==========================================================================
                             STRINGLIST Helpers
-==============================================================================*/
+===========================================================================*/
 
 
-/**==========================================================================**/
+/**=======================================================================**/
 void SCardHelper_AppendStringListToPyObject(
     STRINGLIST* source, PyObject** ptarget )
-/*==============================================================================
+/*===========================================================================
 builds a Python list from a STRINGLIST; the multi-string list in the STRINGLIST
 is stored as series of null-terminated strings terminated by a null,
 e.g. item0\0item2\0lastitem\0\0)
-==============================================================================*/
+===========================================================================*/
 {
     unsigned int cStr;
     char* p=source->ac;
@@ -1156,11 +1158,11 @@ e.g. item0\0item2\0lastitem\0\0)
 
 }
 
-/**==========================================================================**/
+/**=======================================================================**/
 STRINGLIST* SCardHelper_PyStringListToStringList(PyObject* source)
-/*==============================================================================
+/*===========================================================================
 build a Python string list from a STRINGLIST
-==============================================================================*/
+===========================================================================*/
 {
... 528 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pyscard.git



More information about the Python-modules-commits mailing list