[Pcsclite-git-commit] [PCSC] 01/05: UnitaryTests: Python3: use print() function

Ludovic Rousseau rousseau at moszumanska.debian.org
Wed Feb 15 22:53:32 UTC 2017


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

rousseau pushed a commit to branch master
in repository PCSC.

commit 876403e6a48070f26fb7eb1211b7bb2df5e52ed1
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Wed Feb 15 23:45:00 2017 +0100

    UnitaryTests: Python3: use print() function
    
    Use:
    from __future__ import print_function
    to make the same Python code to work with both Python 2 and Python 3.
---
 .../FEATURE_CCID_ESC_COMMAND_Gemalto_features.py   | 77 +++++++++++-----------
 UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py    | 11 ++--
 UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py         |  9 +--
 UnitaryTests/MCT_ReaderDirect.py                   | 28 ++++----
 UnitaryTests/SCardBeginTransaction_Disconnect.py   |  5 +-
 .../SCardBeginTransaction_ExclusiceMode.py         |  5 +-
 UnitaryTests/SCardBeginTransaction_Reset.py        | 11 ++--
 UnitaryTests/SCardBeginTransaction_deadlock.py     | 35 +++++-----
 UnitaryTests/SCardBlockingBehaviourTest.py         | 49 +++++++-------
 UnitaryTests/SCardCancel.py                        | 13 ++--
 UnitaryTests/SCardCancel2.py                       |  9 +--
 UnitaryTests/SCardCancel3.py                       | 21 +++---
 UnitaryTests/SCardConnect_DIRECT.py                | 13 ++--
 UnitaryTests/SCardConnect_DIRECT2.py               | 11 ++--
 UnitaryTests/SCardEndTransaction_extra_call.py     | 15 +++--
 UnitaryTests/SCardExclusiveBehaviour.py            | 21 ++++--
 UnitaryTests/SCardGetAttrib.py                     | 11 ++--
 UnitaryTests/SCardGetStatusChange.py               | 15 +++--
 UnitaryTests/SCardGetStatusChange2.py              | 15 +++--
 UnitaryTests/SCardReconnect.py                     |  7 +-
 UnitaryTests/SCardStatus.py                        | 29 ++++----
 UnitaryTests/SCard_fork.py                         | 25 +++----
 UnitaryTests/ThreadSafe.py                         |  7 +-
 UnitaryTests/ThreadSafeConnect.py                  | 15 +++--
 UnitaryTests/control_get_firmware.py               | 13 ++--
 UnitaryTests/control_switch_interface.py           | 15 +++--
 UnitaryTests/getAttrib.py                          | 12 ++--
 UnitaryTests/reset_card.py                         |  9 +--
 UnitaryTests/stress_apdu.py                        | 15 +++--
 UnitaryTests/stress_get_firmware.py                | 11 ++--
 UnitaryTests/transmit_loop.py                      |  7 +-
 31 files changed, 290 insertions(+), 249 deletions(-)

diff --git a/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py b/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py
index 891e1f0..6bf2b1c 100755
--- a/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py
+++ b/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT,
     SCARD_LEAVE_CARD, FEATURE_CCID_ESC_COMMAND,
@@ -57,9 +58,9 @@ def main():
     get_tlv_properties = hasFeature(feature_list, FEATURE_GET_TLV_PROPERTIES)
     if get_tlv_properties:
         tlv = getTlvProperties(card_connection)
-        print "Reader:   ", readers()[0]
-        print "IdVendor:  0x%04X" % tlv['PCSCv2_PART10_PROPERTY_wIdVendor']
-        print "IdProduct: 0x%04X" % tlv['PCSCv2_PART10_PROPERTY_wIdProduct']
+        print("Reader:   ", readers()[0])
+        print("IdVendor:  0x%04X" % tlv['PCSCv2_PART10_PROPERTY_wIdVendor'])
+        print("IdProduct: 0x%04X" % tlv['PCSCv2_PART10_PROPERTY_wIdProduct'])
 
     ccid_esc_command = hasFeature(feature_list, FEATURE_CCID_ESC_COMMAND)
     if ccid_esc_command is None:
@@ -71,43 +72,43 @@ def main():
     try:
         res = card_connection.control(ccid_esc_command, firmware_features)
     except SmartcardException, ex:
-        print "Failed:", ex
+        print("Failed:", ex)
         return
 
-    print res
-    print "LogicalLCDLineNumber (Logical number of LCD lines):", res[0]
-    print "LogicalLCDRowNumber (Logical number of characters per LCD line):", res[1]
-    print "LcdInfo:", res[2]
-    print "  b0 indicates if scrolling available:", test_bit(res[2], 0)
-    print "EntryValidationCondition:", res[3]
-
-    print "PC/SCv2 features:"
-    print " VerifyPinStart:", test_bit(res[4], 0)
-    print " VerifyPinFinish:", test_bit(res[4], 1)
-    print " ModifyPinStart:", test_bit(res[4], 2)
-    print " ModifyPinFinish:", test_bit(res[4], 3)
-    print " GetKeyPressed:", test_bit(res[4], 4)
-    print " VerifyPinDirect:", test_bit(res[4], 5)
-    print " ModifyPinDirect:", test_bit(res[4], 6)
-    print " Abort:", test_bit(res[4], 7)
-
-    print " GetKey:", test_bit(res[5], 0)
-    print " WriteDisplay:", test_bit(res[5], 1)
-    print " SetSpeMessage:", test_bit(res[5], 2)
+    print(res)
+    print("LogicalLCDLineNumber (Logical number of LCD lines):", res[0])
+    print("LogicalLCDRowNumber (Logical number of characters per LCD line):", res[1])
+    print("LcdInfo:", res[2])
+    print("  b0 indicates if scrolling available:", test_bit(res[2], 0))
+    print("EntryValidationCondition:", res[3])
+
+    print("PC/SCv2 features:")
+    print(" VerifyPinStart:", test_bit(res[4], 0))
+    print(" VerifyPinFinish:", test_bit(res[4], 1))
+    print(" ModifyPinStart:", test_bit(res[4], 2))
+    print(" ModifyPinFinish:", test_bit(res[4], 3))
+    print(" GetKeyPressed:", test_bit(res[4], 4))
+    print(" VerifyPinDirect:", test_bit(res[4], 5))
+    print(" ModifyPinDirect:", test_bit(res[4], 6))
+    print(" Abort:", test_bit(res[4], 7))
+
+    print(" GetKey:", test_bit(res[5], 0))
+    print(" WriteDisplay:", test_bit(res[5], 1))
+    print(" SetSpeMessage:", test_bit(res[5], 2))
     # bits 3-7 are RFU
     # bytes 6 and 7 are RFU
 
-    print " bTimeOut2:", test_bit(res[8], 0)
+    print(" bTimeOut2:", test_bit(res[8], 0))
     bListSupportedLanguages = test_bit(res[8], 1)
-    print " bListSupportedLanguages:", bListSupportedLanguages
+    print(" bListSupportedLanguages:", bListSupportedLanguages)
     if bListSupportedLanguages:
         try:
             # Reader is able to indicate the list of supported languages
             # through CCID-ESC 0x6B
             languages = card_connection.control(ccid_esc_command, [0x6B])
         except SmartcardException, ex:
-            print "Failed:", ex
-        print " ", languages
+            print("Failed:", ex)
+        print(" ", languages)
         languages = iter(languages)
         for low, high in izip(languages, languages):
             lang_x = high * 256 + low
@@ -115,24 +116,24 @@ def main():
                 lang_t = USBLangID[lang_x]
             except KeyError:
                 lang_t = "unkonwn"
-            print "  0x%04X: %s" % (lang_x, lang_t)
+            print("  0x%04X: %s" % (lang_x, lang_t))
 
-    print " bNumberMessageFix:", test_bit(res[8], 2)
-    print " bPPDUSupportOverXferBlock:", test_bit(res[8], 3)
-    print " bPPDUSupportOverEscape:", test_bit(res[8], 4)
+    print(" bNumberMessageFix:", test_bit(res[8], 2))
+    print(" bPPDUSupportOverXferBlock:", test_bit(res[8], 3))
+    print(" bPPDUSupportOverEscape:", test_bit(res[8], 4))
     # bits 5-7 are RFU
     # bytes 9, 10 and 11 and RFU
 
-    print "VersionNumber:", res[12]
-    print "MinimumPINSize:", res[13]
-    print "MaximumPINSize:", res[14]
+    print("VersionNumber:", res[12])
+    print("MinimumPINSize:", res[13])
+    print("MaximumPINSize:", res[14])
     Firewall = test_bit(res[15], 0)
-    print "Firewall:", Firewall
+    print("Firewall:", Firewall)
     # bits 1-7 are RFU
 
     if Firewall:
-        print "FirewalledCommand_SW1: 0x%02X" % res[16]
-        print "FirewalledCommand_SW2: 0x%02X" % res[17]
+        print("FirewalledCommand_SW1: 0x%02X" % res[16])
+        print("FirewalledCommand_SW2: 0x%02X" % res[17])
     # bytes 18-20 are RFU
 
 if __name__ == "__main__":
diff --git a/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py b/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py
index f0d3742..852602b 100755
--- a/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py
+++ b/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py
@@ -24,6 +24,7 @@
 # DRIVER_OPTION_CCID_EXCHANGE_AUTHORIZED bit in the ifdDriverOptions
 # option of the CCID driver Info.plist file
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import (getFeatureRequest, hasFeature,
     getTlvProperties, FEATURE_CCID_ESC_COMMAND, SCARD_SHARE_DIRECT)
@@ -49,12 +50,12 @@ if tlv['PCSCv2_PART10_PROPERTY_wIdVendor'] == 0x0F14 \
     # proprietary escape command for Xiring Leo readers
     version = [ord(c) for c in "VERSION"]
     res = card_connection.control(ccid_esc_command, version)
-    print res
-    print "VERSION:", ''.join([chr(x) for x in res])
+    print(res)
+    print("VERSION:", ''.join([chr(x) for x in res]))
 
     serial = [ord(c) for c in "GET_SN"]
     res = card_connection.control(ccid_esc_command, serial)
-    print res
-    print "GET_SN:", ''.join([chr(x) for x in res])
+    print(res)
+    print("GET_SN:", ''.join([chr(x) for x in res]))
 else:
-    print "Xiring Leo reader not found"
+    print("Xiring Leo reader not found")
diff --git a/UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py b/UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py
index fdc8fb2..819d23a 100755
--- a/UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py
+++ b/UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py
@@ -24,13 +24,14 @@
 # DRIVER_OPTION_CCID_EXCHANGE_AUTHORIZED bit in the ifdDriverOptions
 # option of the CCID driver Info.plist file
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import getTlvProperties, SCARD_SHARE_DIRECT
 
 # for each reader
 for reader in readers():
-    print
-    print "Reader:", reader
+    print()
+    print("Reader:", reader)
 
     card_connection = reader.createConnection()
     card_connection.connect(mode=SCARD_SHARE_DIRECT)
@@ -41,6 +42,6 @@ for reader in readers():
     for key in sorted(tlv):
         if key in ["PCSCv2_PART10_PROPERTY_wIdProduct",
                 "PCSCv2_PART10_PROPERTY_wIdVendor"]:
-            print "%s: 0x%04X" % (key, tlv[key])
+            print("%s: 0x%04X" % (key, tlv[key]))
         else:
-            print "%s: %s" % (key, tlv[key])
+            print("%s: %s" % (key, tlv[key]))
diff --git a/UnitaryTests/MCT_ReaderDirect.py b/UnitaryTests/MCT_ReaderDirect.py
index 82bd6c8..a6a562f 100755
--- a/UnitaryTests/MCT_ReaderDirect.py
+++ b/UnitaryTests/MCT_ReaderDirect.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT,
     SCARD_LEAVE_CARD, FEATURE_MCT_READER_DIRECT, getFeatureRequest, hasFeature)
@@ -26,7 +27,7 @@ from smartcard.util import toHexString
 
 def parse_info(bytes):
     """ parse the SECODER INFO answer """
-    print "parse the SECODER INFO answer:", toHexString(bytes)
+    print("parse the SECODER INFO answer:", toHexString(bytes))
 
     sw = bytes[-2:]
     del bytes[-2:]
@@ -36,26 +37,27 @@ def parse_info(bytes):
         length = bytes[1]
         data = bytes[2:2 + length]
 
-        print "tag: %02X, length: %2d:" % (tag, length),
+        print("tag: %02X, length: %2d:" % (tag, length), end=' ')
         if tag in [0x40, 0x80, 0x81, 0x83, 0x84]:
-            print "'%s'" % ''.join([chr(x) for x in data])
+            print("'%s'" % ''.join([chr(x) for x in data]))
         else:
-            print toHexString(data)
+            print(toHexString(data))
 
         del bytes[:2 + length]
-    print "SW:", toHexString(sw)
+    print("SW:", toHexString(sw))
 
 
 def parse_select(bytes):
     """ parse the SECODER SELECT APPLICATION answer """
-    print "parse the SECODER SELECT APPLICATION answer:", toHexString(bytes)
+    print("parse the SECODER SELECT APPLICATION answer:",
+            toHexString(bytes))
 
-    print "Activation ID:", toHexString(bytes[0:4])
-    print "Interface Version: '%s'" % ''.join([chr(x) for x in bytes[5:11]])
-    print "Language Code:", toHexString(bytes[11:15])
-    print "CSI:", toHexString(bytes[15:18])
-    print "Application Identifier:", toHexString(bytes[18:23])
-    print "SW:", toHexString(bytes[23:25])
+    print("Activation ID:", toHexString(bytes[0:4]))
+    print("Interface Version: '%s'" % ''.join([chr(x) for x in bytes[5:11]]))
+    print("Language Code:", toHexString(bytes[11:15]))
+    print("CSI:", toHexString(bytes[15:18]))
+    print("Application Identifier:", toHexString(bytes[18:23]))
+    print("SW:", toHexString(bytes[23:25]))
 
 
 def main():
@@ -65,7 +67,7 @@ def main():
         disposition=SCARD_LEAVE_CARD)
 
     feature_list = getFeatureRequest(card_connection)
-    #print getPinProperties(card_connection)
+    #print(getPinProperties(card_connection))
 
     mct_reader_direct = hasFeature(feature_list, FEATURE_MCT_READER_DIRECT)
     if mct_reader_direct is None:
diff --git a/UnitaryTests/SCardBeginTransaction_Disconnect.py b/UnitaryTests/SCardBeginTransaction_Disconnect.py
index e39d0d3..9567224 100755
--- a/UnitaryTests/SCardBeginTransaction_Disconnect.py
+++ b/UnitaryTests/SCardBeginTransaction_Disconnect.py
@@ -21,6 +21,7 @@
 # corresponding SCardEndTransaction(). OpenSC "pkcs11-tool -I" exhibits
 # such a behavior.
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
@@ -31,9 +32,9 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
 if hresult != SCARD_S_SUCCESS:
diff --git a/UnitaryTests/SCardBeginTransaction_ExclusiceMode.py b/UnitaryTests/SCardBeginTransaction_ExclusiceMode.py
index ecc493a..8f2718f 100755
--- a/UnitaryTests/SCardBeginTransaction_ExclusiceMode.py
+++ b/UnitaryTests/SCardBeginTransaction_ExclusiceMode.py
@@ -19,6 +19,7 @@
 # Alioth bug [#312960] SCardDisconnect when other context has transaction
 # fixed in revisions 5572 and 5574
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
@@ -29,9 +30,9 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext1, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 hresult, hcontext2 = SCardEstablishContext(SCARD_SCOPE_USER)
 if hresult != SCARD_S_SUCCESS:
diff --git a/UnitaryTests/SCardBeginTransaction_Reset.py b/UnitaryTests/SCardBeginTransaction_Reset.py
index b478740..21f774e 100755
--- a/UnitaryTests/SCardBeginTransaction_Reset.py
+++ b/UnitaryTests/SCardBeginTransaction_Reset.py
@@ -20,6 +20,7 @@
 # transaction is ongoing.
 # Test for the patch in 74656f24db3da1532040a1775ceffa225fbc3d00
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 from time import sleep
@@ -31,9 +32,9 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext1, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 hresult, hcontext2 = SCardEstablishContext(SCARD_SCOPE_USER)
 if hresult != SCARD_S_SUCCESS:
@@ -57,14 +58,14 @@ if hresult != SCARD_S_SUCCESS:
     # we should get an error here
     # but the card shall not be reseted
     if hresult == SCARD_E_SHARING_VIOLATION:
-        print "We got the expected error"
+        print("We got the expected error")
     else:
         raise BaseSCardException(hresult)
 
 hresult, reader, state, protocol, atr = SCardStatus(hcard1)
 if hresult == SCARD_W_RESET_CARD:
-    print "The test failed"
-    print "The card should not been reseted"
+    print("The test failed")
+    print("The card should not been reseted")
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
diff --git a/UnitaryTests/SCardBeginTransaction_deadlock.py b/UnitaryTests/SCardBeginTransaction_deadlock.py
index 38e2021..3f2b9ae 100755
--- a/UnitaryTests/SCardBeginTransaction_deadlock.py
+++ b/UnitaryTests/SCardBeginTransaction_deadlock.py
@@ -21,13 +21,14 @@
 # http://archives.neohapsis.com/archives/dev/muscle/2012-q2/0109.html
 # fixed in revisions 6358, 6359, 6360 and 6361
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import threading
 import time
 
 def myThread(reader):
-    print "thread 2: SCardConnect"
+    print("thread 2: SCardConnect")
     hresult, hcard2, dwActiveProtocol = SCardConnect(hcontext1, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
@@ -37,12 +38,12 @@ def myThread(reader):
 
     """
     # check for SCardBeginTransaction
-    print "thread 2: SCardBeginTransaction"
+    print("thread 2: SCardBeginTransaction")
     hresult = SCardBeginTransaction(hcard2)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
 
-    print "thread 2: SCardEndTransaction"
+    print("thread 2: SCardEndTransaction")
     hresult = SCardEndTransaction(hcard2, SCARD_LEAVE_CARD)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
@@ -51,45 +52,45 @@ def myThread(reader):
     """
     # check for SCardTransmit()
     SELECT = [0x00, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00]
-    print "thread 2: SCardTransmit"
+    print("thread 2: SCardTransmit")
     hresult, response = SCardTransmit(hcard2, dwActiveProtocol, SELECT)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
-    print response
+    print(response)
     """
 
     """
     # check for SCardStatus()
-    print "thread 2: SCardStatus"
+    print("thread 2: SCardStatus")
     hresult, reader, state, protocol, atr = SCardStatus(hcard2)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
     """
 
     # check for SCardReconnect()
-    print "thread 2: SCardReconnect"
+    print("thread 2: SCardReconnect")
     hresult, dwActiveProtocol = SCardReconnect(hcard2,
         SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY, SCARD_LEAVE_CARD)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
 
-    print "thread 2: SCardDisconnect"
+    print("thread 2: SCardDisconnect")
     hresult = SCardDisconnect(hcard2, SCARD_LEAVE_CARD)
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
 
-print "thread 1: SCardEstablishContext"
+print("thread 1: SCardEstablishContext")
 hresult, hcontext1 = SCardEstablishContext(SCARD_SCOPE_USER)
 if hresult != SCARD_S_SUCCESS:
     raise EstablishContextException(hresult)
 
-print "thread 1: SCardListReaders"
+print("thread 1: SCardListReaders")
 hresult, readers = SCardListReaders(hcontext1, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 # second thread
 t = threading.Thread(target=myThread, args=(reader, ))
@@ -98,19 +99,19 @@ t.start()
 # wait for the 1st thread to begin a transaction
 time.sleep(0.5)
 
-print "thread 1: SCardConnect"
+print("thread 1: SCardConnect")
 hresult, hcard1, dwActiveProtocol = SCardConnect(hcontext1, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
-print "thread 1: SCardBeginTransaction"
+print("thread 1: SCardBeginTransaction")
 hresult = SCardBeginTransaction(hcard1)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
 time.sleep(2)
 
-print "thread 1: SCardEndTransaction"
+print("thread 1: SCardEndTransaction")
 hresult = SCardEndTransaction(hcard1, SCARD_LEAVE_CARD)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
@@ -118,12 +119,12 @@ if hresult != SCARD_S_SUCCESS:
 # give time to thread2 to finish
 time.sleep(1)
 
-print "thread 1: SCardDisconnect"
+print("thread 1: SCardDisconnect")
 hresult = SCardDisconnect(hcard1, SCARD_LEAVE_CARD)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
-print "thread 1: SCardReleaseContext"
+print("thread 1: SCardReleaseContext")
 hresult = SCardReleaseContext(hcontext1)
 if hresult != SCARD_S_SUCCESS:
     raise ReleaseContextException(hresult)
diff --git a/UnitaryTests/SCardBlockingBehaviourTest.py b/UnitaryTests/SCardBlockingBehaviourTest.py
index 246b110..3139386 100755
--- a/UnitaryTests/SCardBlockingBehaviourTest.py
+++ b/UnitaryTests/SCardBlockingBehaviourTest.py
@@ -29,6 +29,7 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
+from __future__ import print_function
 import sys
 import thread
 import time
@@ -45,16 +46,16 @@ unblocked = False
 def check(testFunctionName, hresult, duration):
     """ check """
     if hresult != SCARD_S_SUCCESS:
-        print "%s failed: %s" % (testFunctionName, SCardGetErrorMessage(hresult))
-        print 'Failure for "Sharing violation" are OK for non blocking calls'
-    print "%s finished after %ss" % (testFunctionName, duration)
+        print("%s failed: %s" % (testFunctionName, SCardGetErrorMessage(hresult)))
+        print('Failure for "Sharing violation" are OK for non blocking calls')
+    print("%s finished after %ss" % (testFunctionName, duration))
 
 
 def SCardReconnectTest(hcontextTest, hcardTest, readerName):
     """ SCardReconnectTest """
     global unblocked
     testFunctionName = sys._getframe().f_code.co_name
-    print "Test thread for %s" % testFunctionName
+    print("Test thread for %s" % testFunctionName)
     before = time.time()
     hresult, dwDisposition = SCardReconnect(hcardTest, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T0, SCARD_LEAVE_CARD)
     check(testFunctionName, hresult, time.time() - before)
@@ -65,7 +66,7 @@ def SCardGetAttribTest(hcontextTest, hcardTest, readerName):
     """ SCardGetAttribTest """
     global unblocked
     testFunctionName = sys._getframe().f_code.co_name
-    print "Test thread for %s" % testFunctionName
+    print("Test thread for %s" % testFunctionName)
     before = time.time()
     hresult, attrib = SCardGetAttrib(hcardTest, SCARD_ATTR_DEVICE_FRIENDLY_NAME_A)
     check(testFunctionName, hresult, time.time() - before)
@@ -76,7 +77,7 @@ def SCardTransmitTest(hcontextTest, hcardTest, readerName):
     """ SCardTransmitTest """
     global unblocked
     testFunctionName = sys._getframe().f_code.co_name
-    print "Test thread for %s" % testFunctionName
+    print("Test thread for %s" % testFunctionName)
     SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
     DF_TELECOM = [0x7F, 0x10]
     before = time.time()
@@ -89,7 +90,7 @@ def SCardStatusTest(hcontextTest, hcardTest, readerName):
     """ SCardStatusTest """
     global unblocked
     testFunctionName = sys._getframe().f_code.co_name
-    print "Test thread for %s" % testFunctionName
+    print("Test thread for %s" % testFunctionName)
     before = time.time()
     hresult, reader, state, protocol, atr = SCardStatus(hcardTest)
     check(testFunctionName, hresult, time.time() - before)
@@ -100,7 +101,7 @@ def SCardConnectTest(hcontextTest, hcardTest, readerName):
     """ SCardConnectTest """
     global unblocked
     testFunctionName = sys._getframe().f_code.co_name
-    print "Test thread for %s" % testFunctionName
+    print("Test thread for %s" % testFunctionName)
     hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
     if hresult != SCARD_S_SUCCESS:
         raise EstablishContextException(hresult)
@@ -117,12 +118,12 @@ def SCardBeginTransactionTest(hcontextTest, hcardTest, readerName):
     """ SCardBeginTransactionTest """
     global unblocked
     testFunctionName = sys._getframe().f_code.co_name
-    print "Test thread for %s" % testFunctionName
+    print("Test thread for %s" % testFunctionName)
     before = time.time()
     hresult = SCardBeginTransaction(hcardTest)
     if hresult != SCARD_S_SUCCESS:
-        print "%s failed: %s" % (testFunctionName, SCardGetErrorMessage(hresult))
-        print 'Failure for "Sharing violation" are OK for non blocking calls'
+        print("%s failed: %s" % (testFunctionName, SCardGetErrorMessage(hresult)))
+        print('Failure for "Sharing violation" are OK for non blocking calls')
     hresult = SCardEndTransaction(hcardTest, SCARD_LEAVE_CARD)
     check(testFunctionName, hresult, time.time() - before)
     unblocked = True
@@ -131,7 +132,7 @@ def SCardBeginTransactionTest(hcontextTest, hcardTest, readerName):
 #def TemplateTest(hcontextTest, hcardTest, readerName):
 #    global unblocked
 #    testFunctionName = sys._getframe().f_code.co_name
-#    print "Test thread for %s" % testFunctionName
+#    print("Test thread for %s" % testFunctionName)
 #    before = time.time()
 #    hresult, attrib = Template(hcardTest, SCARD_ATTR_DEVICE_FRIENDLY_NAME_A)
 #    check(testFunctionName, hresult, time.time() - before)
@@ -172,17 +173,17 @@ def Connect(index=0):
     hresult, readers = SCardListReaders(hcontext, [])
     if hresult != SCARD_S_SUCCESS:
         raise ListReadersException(hresult)
-    print 'PC/SC Readers:', readers
+    print('PC/SC Readers:', readers)
     if (len(readers) <= 0):
         raise NoReadersException()
     reader = readers[index]
-    print "Using reader:", reader
+    print("Using reader:", reader)
 
     # Connect in SCARD_SHARE_SHARED mode
     hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
         SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
     if hresult != SCARD_S_SUCCESS:
-        print "SCardConnect failed"
+        print("SCardConnect failed")
         raise BaseSCardException(hresult)
     return hcontext, hcard, reader
 
@@ -197,7 +198,7 @@ def ConnectWithReader(readerName):
     hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, readerName,
         SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
     if hresult != SCARD_S_SUCCESS:
-        print "SCardConnect failed"
+        print("SCardConnect failed")
         raise BaseSCardException(hresult)
     return hcontext, hcard
 
@@ -211,7 +212,7 @@ def main():
     NORMAL = "\033[00m"
 
     #if len(sys.argv) < 4:
-    #    print usage
+    #    print(usage)
     #    sys.exit(1)
     # Allow to specify test name
     # Options:
@@ -230,14 +231,14 @@ def main():
         # Start test function in a new thread
         SCardBeginTransaction(hcard)
         unblocked = False
-        print
-        print "Testing %s, expecting" % testTarget,
+        print()
+        print("Testing %s, expecting" % testTarget, end=' ')
         if tests[testTarget][1]:
-            print "blocking"
+            print("blocking")
         else:
-            print "non blocking"
+            print("non blocking")
         thread.start_new_thread(tests[testTarget][0], (hcontextTest, hcardTest, readerName))
-        #print "Thread started"
+        #print("Thread started")
         time.sleep(1)
         if (unblocked and tests[testTarget][1]) or ((not unblocked) and (not tests[testTarget][1])):
             failed = True
@@ -249,9 +250,9 @@ def main():
         time.sleep(1)
 
         if failed:
-            print RED + "Test for " + testTarget + " FAILED!" + NORMAL
+            print(RED + "Test for " + testTarget + " FAILED!" + NORMAL)
         else:
-            print BLUE + "Test for " + testTarget + " succeeded" + NORMAL
+            print(BLUE + "Test for " + testTarget + " succeeded" + NORMAL)
 
 if __name__ == '__main__':
     main()
diff --git a/UnitaryTests/SCardCancel.py b/UnitaryTests/SCardCancel.py
index cbc103d..37bde1c 100755
--- a/UnitaryTests/SCardCancel.py
+++ b/UnitaryTests/SCardCancel.py
@@ -17,6 +17,7 @@
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import threading
@@ -25,10 +26,10 @@ import time
 
 def cancel():
     time.sleep(1)
-    print "cancel"
+    print("cancel")
     hresult = SCardCancel(hcontext)
     if hresult != 0:
-        print 'Failed to SCardCancel: ' + SCardGetErrorMessage(hresult)
+        print('Failed to SCardCancel: ' + SCardGetErrorMessage(hresult))
 
 hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
 if hresult != SCARD_S_SUCCESS:
@@ -37,7 +38,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 readerstates = {}
 for reader in readers:
@@ -45,7 +46,7 @@ for reader in readers:
 hresult, newstates = SCardGetStatusChange(hcontext, 0, readerstates.values())
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print newstates
+print(newstates)
 for state in newstates:
     readername, eventstate, atr = state
     readerstates[readername] = (readername, eventstate)
@@ -54,7 +55,7 @@ t = threading.Thread(target=cancel)
 t.start()
 
 hresult, newstates = SCardGetStatusChange(hcontext, 10000, readerstates.values())
-print "SCardGetStatusChange()", SCardGetErrorMessage(hresult)
+print("SCardGetStatusChange()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS and hresult != SCARD_E_TIMEOUT:
     if SCARD_E_CANCELLED == hresult:
         pass
@@ -62,6 +63,6 @@ if hresult != SCARD_S_SUCCESS and hresult != SCARD_E_TIMEOUT:
         raise BaseSCardException(hresult)
 
 hresult = SCardReleaseContext(hcontext)
-print "SCardReleaseContext()", SCardGetErrorMessage(hresult)
+print("SCardReleaseContext()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS:
     raise ReleaseContextException(hresult)
diff --git a/UnitaryTests/SCardCancel2.py b/UnitaryTests/SCardCancel2.py
index 2bb8e95..9e4715d 100755
--- a/UnitaryTests/SCardCancel2.py
+++ b/UnitaryTests/SCardCancel2.py
@@ -20,6 +20,7 @@
 # SCardCancel() should do nothing if no cancellable call is ongoing
 # bug fixed in revision 5344
 
+from __future__ import print_function
 from smartcard.scard import *
 
 try:
@@ -27,21 +28,21 @@ try:
     if hresult != SCARD_S_SUCCESS:
         raise Exception('Failed to establish context : ' +
                         SCardGetErrorMessage(hresult))
-    print 'Context established!'
+    print('Context established!')
 
     try:
         hresult = SCardCancel(hcontext)
         if hresult != SCARD_S_SUCCESS:
             raise Exception('Failed to cancel context : ' +
                             SCardGetErrorMessage(hresult))
-        print 'context canceled'
+        print('context canceled')
 
     finally:
         hresult = SCardReleaseContext(hcontext)
         if hresult != SCARD_S_SUCCESS:
             raise Exception('Failed to release context: ' +
                             SCardGetErrorMessage(hresult))
-        print 'Released context.'
+        print('Released context.')
 
 except Exception, message:
-    print "Exception:", message
+    print("Exception:", message)
diff --git a/UnitaryTests/SCardCancel3.py b/UnitaryTests/SCardCancel3.py
index 51af9c9..ce76668 100755
--- a/UnitaryTests/SCardCancel3.py
+++ b/UnitaryTests/SCardCancel3.py
@@ -24,6 +24,7 @@
 
 # The bug has been fixed in 57b0ba5a200bcbf1c489d39261340324392a8e8a
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import threading
@@ -34,15 +35,15 @@ import sys
 def getstatuschange():
     # this call will be cancelled
     hresult, newstates = SCardGetStatusChange(hcontext, 10000, readerstates.values())
-    print "SCardGetStatusChange()", SCardGetErrorMessage(hresult)
+    print("SCardGetStatusChange()", SCardGetErrorMessage(hresult))
     if hresult != SCARD_S_SUCCESS and hresult != SCARD_E_TIMEOUT:
         if SCARD_E_CANCELLED == hresult:
-            print "Cancelled"
+            print("Cancelled")
         else:
             raise BaseSCardException(hresult)
-    print "Finished"
+    print("Finished")
 
-    print "Remove the card and press enter"
+    print("Remove the card and press enter")
     sys.stdin.read(1)
 
     # try another PC/SC call. It should return SCARD_W_REMOVED_CARD and
@@ -52,7 +53,7 @@ def getstatuschange():
         if hresult != SCARD_W_REMOVED_CARD:
             raise BaseSCardException(hresult)
         else:
-            print "Card removed"
+            print("Card removed")
 
 hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
 if hresult != SCARD_S_SUCCESS:
@@ -61,7 +62,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 readerstates = {}
 for reader in readers:
@@ -69,7 +70,7 @@ for reader in readers:
 hresult, newstates = SCardGetStatusChange(hcontext, 0, readerstates.values())
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print newstates
+print(newstates)
 for state in newstates:
     readername, eventstate, atr = state
     readerstates[readername] = (readername, eventstate)
@@ -84,13 +85,13 @@ t = threading.Thread(target=getstatuschange)
 t.start()
 
 time.sleep(1)
-print "cancel"
+print("cancel")
 hresult = SCardCancel(hcontext)
 if hresult != SCARD_S_SUCCESS:
-    print 'Failed to SCardCancel: ' + SCardGetErrorMessage(hresult)
+    print('Failed to SCardCancel: ' + SCardGetErrorMessage(hresult))
 
 time.sleep(5)
 hresult = SCardReleaseContext(hcontext)
-print "SCardReleaseContext()", SCardGetErrorMessage(hresult)
+print("SCardReleaseContext()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS:
     raise ReleaseContextException(hresult)
diff --git a/UnitaryTests/SCardConnect_DIRECT.py b/UnitaryTests/SCardConnect_DIRECT.py
index 35416ca..d3732b7 100755
--- a/UnitaryTests/SCardConnect_DIRECT.py
+++ b/UnitaryTests/SCardConnect_DIRECT.py
@@ -21,6 +21,7 @@
 # has been implemented in revision 4332 but reverted in revision 4940 so
 # that the protocol is not negociated again
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
@@ -31,9 +32,9 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 # the card should be reseted or inserted just before execution
 
@@ -43,7 +44,7 @@ hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
-print "dwActiveProtocol:", dwActiveProtocol
+print("dwActiveProtocol:", dwActiveProtocol)
 
 # Reconnect in SCARD_SHARE_DIRECT mode
 hresult, dwActiveProtocol = SCardReconnect(hcard,
@@ -52,7 +53,7 @@ if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
 # ActiveProtocol should be SCARD_PROTOCOL_UNDEFINED (0)
-print "dwActiveProtocol:", dwActiveProtocol
+print("dwActiveProtocol:", dwActiveProtocol)
 if SCARD_PROTOCOL_UNDEFINED != dwActiveProtocol:
     raise Exception('dwActiveProtocol should be SCARD_PROTOCOL_UNDEFINED')
 
@@ -66,7 +67,7 @@ hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
-print "dwActiveProtocol:", dwActiveProtocol
+print("dwActiveProtocol:", dwActiveProtocol)
 oldActiveProtocol = dwActiveProtocol
 
 # Reconnect in SCARD_SHARE_DIRECT mode
@@ -76,7 +77,7 @@ if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
 # ActiveProtocol should be SCARD_PROTOCOL_UNDEFINED (0)
-print "dwActiveProtocol:", dwActiveProtocol
+print("dwActiveProtocol:", dwActiveProtocol)
 if oldActiveProtocol != dwActiveProtocol:
     raise Exception('dwActiveProtocol should be like before')
 
diff --git a/UnitaryTests/SCardConnect_DIRECT2.py b/UnitaryTests/SCardConnect_DIRECT2.py
index 8bb02b7..34bcde8 100755
--- a/UnitaryTests/SCardConnect_DIRECT2.py
+++ b/UnitaryTests/SCardConnect_DIRECT2.py
@@ -31,6 +31,7 @@
 # same issue with Reconnect instead of connect
 # bug fixed in revision 4940
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
@@ -43,10 +44,10 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 # Connect in SCARD_SHARE_SHARED mode
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
@@ -58,7 +59,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, response = SCardTransmit(hcard, dwActiveProtocol, SELECT)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print response
+print(response)
 
 # Disconnect
 hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
@@ -86,7 +87,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, response = SCardTransmit(hcard, dwActiveProtocol, SELECT)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print response
+print(response)
 
 # Reconnect in SCARD_SHARE_DIRECT mode
 hresult, dwActiveProtocol = SCardReconnect(hcard,
@@ -109,7 +110,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, response = SCardTransmit(hcard, dwActiveProtocol, SELECT)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print response
+print(response)
 
 # Disconnect
 hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
diff --git a/UnitaryTests/SCardEndTransaction_extra_call.py b/UnitaryTests/SCardEndTransaction_extra_call.py
index a7c719c..5ab10a2 100755
--- a/UnitaryTests/SCardEndTransaction_extra_call.py
+++ b/UnitaryTests/SCardEndTransaction_extra_call.py
@@ -20,6 +20,7 @@
 # SCardEndTransaction() should return SCARD_E_NOT_TRANSACTED if called
 # more times than SCardBeginTransaction()
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
@@ -30,9 +31,9 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
 if hresult != SCARD_S_SUCCESS:
@@ -41,19 +42,19 @@ if hresult != SCARD_S_SUCCESS:
 hresult = SCardBeginTransaction(hcard)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print "SCardBeginTransaction()", SCardGetErrorMessage(hresult)
+print("SCardBeginTransaction()", SCardGetErrorMessage(hresult))
 
 hresult = SCardEndTransaction(hcard, SCARD_LEAVE_CARD)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print "first SCardEndTransaction()", SCardGetErrorMessage(hresult)
+print("first SCardEndTransaction()", SCardGetErrorMessage(hresult))
 
 hresult = SCardEndTransaction(hcard, SCARD_LEAVE_CARD)
-print "second SCardEndTransaction()", SCardGetErrorMessage(hresult)
+print("second SCardEndTransaction()", SCardGetErrorMessage(hresult))
 if hresult == SCARD_E_NOT_TRANSACTED:
-    print "OK"
+    print("OK")
 else:
-    print "ERROR! SCardEndTransaction() should have failed"
+    print("ERROR! SCardEndTransaction() should have failed")
 
 hresult = SCardReleaseContext(hcontext)
 if hresult != SCARD_S_SUCCESS:
diff --git a/UnitaryTests/SCardExclusiveBehaviour.py b/UnitaryTests/SCardExclusiveBehaviour.py
index 9c72f6e..2225119 100755
--- a/UnitaryTests/SCardExclusiveBehaviour.py
+++ b/UnitaryTests/SCardExclusiveBehaviour.py
@@ -32,6 +32,7 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 from smartcard.Exceptions import NoReadersException
@@ -47,11 +48,11 @@ def Connect(mode):
     hresult, readers = SCardListReaders(hcontext, [])
     if hresult != SCARD_S_SUCCESS:
         raise ListReadersException(hresult)
-    print 'PC/SC Readers:', readers
+    print('PC/SC Readers:', readers)
     if (len(readers) <= 0):
         raise NoReadersException()
     reader = readers[0]
-    print "Using reader:", reader
+    print("Using reader:", reader)
 
     hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
         mode, SCARD_PROTOCOL_ANY)
@@ -74,26 +75,32 @@ def main():
 
     hresult, hcontext1, hcard1, readerName = Connect(SCARD_SHARE_EXCLUSIVE)
     if hresult != SCARD_S_SUCCESS:
-        print "Test1: Error creating first exclusive connection % x" % hresult
+        print("Test1: Error creating first exclusive connection % x" %
+                hresult)
         return
 
     hresult, hcontext2, hcardTest2 = ConnectWithReader(readerName, SCARD_SHARE_SHARED)
     if hresult != SCARD_E_SHARING_VIOLATION:
-        print "Test1: Expected %s (SCARD_E_SHARING_VIOLATION) but got %s" % (SCardGetErrorMessage(SCARD_E_SHARING_VIOLATION), SCardGetErrorMessage(hresult))
+        print("Test1: Expected %s (SCARD_E_SHARING_VIOLATION) but got %s"
+                % (SCardGetErrorMessage(SCARD_E_SHARING_VIOLATION),
+                        SCardGetErrorMessage(hresult)))
         return
 
     SCardDisconnect(hcard1, 0)
 
     hresult, hcontext1, hcard1 = ConnectWithReader(readerName, SCARD_SHARE_SHARED)
     if hresult != SCARD_S_SUCCESS:
-        print "Testt2: Error creating first shared connection % x" % hresult
+        print("Testt2: Error creating first shared connection % x" %
+                hresult)
         return
 
     hresult, hcontext2, hcardTest2 = ConnectWithReader(readerName, SCARD_SHARE_EXCLUSIVE)
     if hresult != SCARD_E_SHARING_VIOLATION:
-        print "Test2: Expected %s (SCARD_E_SHARING_VIOLATION) but got %s" % (SCardGetErrorMessage(SCARD_E_SHARING_VIOLATION), SCardGetErrorMessage(hresult))
+        print("Test2: Expected %s (SCARD_E_SHARING_VIOLATION) but got %s"
+                % (SCardGetErrorMessage(SCARD_E_SHARING_VIOLATION),
+                SCardGetErrorMessage(hresult)))
         sys.exit(1)
-    print "Test successful"
+    print("Test successful")
 
 if __name__ == '__main__':
     main()
diff --git a/UnitaryTests/SCardGetAttrib.py b/UnitaryTests/SCardGetAttrib.py
index 98b5472..6f356bd 100755
--- a/UnitaryTests/SCardGetAttrib.py
+++ b/UnitaryTests/SCardGetAttrib.py
@@ -21,6 +21,7 @@
 # SCARD_ATTR_VENDOR_IFD_SERIAL_NO support has been added in ccid 1.3.13
 # SCARD_ATTR_ATR_STRING support has been added in ccid 0.9.0
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 from smartcard.util import toHexString, toASCIIString
@@ -32,7 +33,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 for reader in readers:
     hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
@@ -40,14 +41,14 @@ for reader in readers:
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
 
-    print "reader:", reader
+    print("reader:", reader)
     for attribute in (SCARD_ATTR_VENDOR_IFD_SERIAL_NO, SCARD_ATTR_ATR_STRING):
         hresult, attrib = SCardGetAttrib(hcard, attribute)
-        print hex(attribute),
+        print(hex(attribute), end=' ')
         if hresult != SCARD_S_SUCCESS:
-            print SCardGetErrorMessage(hresult)
+            print(SCardGetErrorMessage(hresult))
         else:
-            print attrib, toHexString(attrib), toASCIIString(attrib)
+            print(attrib, toHexString(attrib), toASCIIString(attrib))
 
     hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
     if hresult != SCARD_S_SUCCESS:
diff --git a/UnitaryTests/SCardGetStatusChange.py b/UnitaryTests/SCardGetStatusChange.py
index ccea184..4d73d6f 100755
--- a/UnitaryTests/SCardGetStatusChange.py
+++ b/UnitaryTests/SCardGetStatusChange.py
@@ -34,6 +34,7 @@
 #  * - FIXME: Mac?
 #  */
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
@@ -63,7 +64,7 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 readerstates = {}
 for reader in readers:
@@ -71,23 +72,23 @@ for reader in readers:
 hresult, newstates = SCardGetStatusChange(hcontext, 0, readerstates.values())
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print newstates
+print(newstates)
 for readerState in newstates:
     readername, eventstate, atr = readerState
     readerstates[readername] = (readername, eventstate)
 
-print "Remove the reader"
+print("Remove the reader")
 
 hresult, newstates = SCardGetStatusChange(hcontext, 10000, readerstates.values())
-print "SCardGetStatusChange()", SCardGetErrorMessage(hresult)
+print("SCardGetStatusChange()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS and hresult != SCARD_E_TIMEOUT:
     raise BaseSCardException(hresult)
 for readerState in newstates:
     readername, eventstate, atr = readerState
-    print readername, hex(eventstate)
-    print parseEventState(eventstate)
+    print(readername, hex(eventstate))
+    print(parseEventState(eventstate))
 
 hresult = SCardReleaseContext(hcontext)
-print "SCardReleaseContext()", SCardGetErrorMessage(hresult)
+print("SCardReleaseContext()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS:
     raise ReleaseContextException(hresult)
diff --git a/UnitaryTests/SCardGetStatusChange2.py b/UnitaryTests/SCardGetStatusChange2.py
index d634de7..4509479 100755
--- a/UnitaryTests/SCardGetStatusChange2.py
+++ b/UnitaryTests/SCardGetStatusChange2.py
@@ -19,31 +19,32 @@
 # Check the return value of SCardGetStatusChange() for unknown readers
 # Before revision 5881 SCardGetStatusChange() returned SCARD_S_SUCCESS
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 
 
 hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
-print "SCardEstablishContext()", SCardGetErrorMessage(hresult)
+print("SCardEstablishContext()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS:
     raise EstablishContextException(hresult)
 
 hresult, readers = SCardListReaders(hcontext, [])
-print "SCardListReaders()", SCardGetErrorMessage(hresult)
-print 'PC/SC Readers:', readers
+print("SCardListReaders()", SCardGetErrorMessage(hresult))
+print('PC/SC Readers:', readers)
 
 readers = ["a", "b"]
-print readers
+print(readers)
 readerstates = {}
 for reader in readers:
     readerstates[reader] = (reader, SCARD_STATE_UNAWARE)
 hresult, newstates = SCardGetStatusChange(hcontext, 10, readerstates.values())
-print "SCardGetStatusChange()", SCardGetErrorMessage(hresult)
+print("SCardGetStatusChange()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print newstates
+print(newstates)
 
 hresult = SCardReleaseContext(hcontext)
-print "SCardReleaseContext()", SCardGetErrorMessage(hresult)
+print("SCardReleaseContext()", SCardGetErrorMessage(hresult))
 if hresult != SCARD_S_SUCCESS:
     raise ReleaseContextException(hresult)
diff --git a/UnitaryTests/SCardReconnect.py b/UnitaryTests/SCardReconnect.py
index 312df50..0592fcb 100755
--- a/UnitaryTests/SCardReconnect.py
+++ b/UnitaryTests/SCardReconnect.py
@@ -20,6 +20,7 @@
 # when the reconnection requests exclusive access and the reader is
 # already shared.
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import sys
@@ -31,10 +32,10 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 # Connect in SCARD_SHARE_SHARED mode
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
@@ -45,7 +46,7 @@ if hresult != SCARD_S_SUCCESS:
 # start here another application using the reader in SCARD_SHARE_SHARED
 # mode
 
-print "Press enter"
+print("Press enter")
 sys.stdin.read(1)
 
 # Reconnect in SCARD_SHARE_EXCLUSIVE mode
diff --git a/UnitaryTests/SCardStatus.py b/UnitaryTests/SCardStatus.py
index 5d34f59..09ddf04 100755
--- a/UnitaryTests/SCardStatus.py
+++ b/UnitaryTests/SCardStatus.py
@@ -18,6 +18,7 @@
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import sys
@@ -30,10 +31,10 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 # Connect in SCARD_SHARE_SHARED mode
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
@@ -44,29 +45,29 @@ if hresult != SCARD_S_SUCCESS:
 hresult, reader, state, protocol, atr = SCardStatus(hcard)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print SCardGetErrorMessage(hresult)
+print(SCardGetErrorMessage(hresult))
 
-print "reader:", reader
-print "state:", hex(state)
-print "protocol:", protocol
-print "atr:", atr
+print("reader:", reader)
+print("state:", hex(state))
+print("protocol:", protocol)
+print("atr:", atr)
 
-print "Press enter"
+print("Press enter")
 sys.stdin.read(1)
 
 hresult, reader, state, protocol, atr = SCardStatus(hcard)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
-print SCardGetErrorMessage(hresult)
+print(SCardGetErrorMessage(hresult))
 
-print "reader:", reader
-print "state:", hex(state)
-print "protocol:", protocol
-print "atr:", atr
+print("reader:", reader)
+print("state:", hex(state))
+print("protocol:", protocol)
+print("atr:", atr)
 
 hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
 if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
 hresult = SCardReleaseContext(hcontext)
-print SCardGetErrorMessage(hresult)
+print(SCardGetErrorMessage(hresult))
diff --git a/UnitaryTests/SCard_fork.py b/UnitaryTests/SCard_fork.py
index 8e57156..f3dfa9f 100755
--- a/UnitaryTests/SCard_fork.py
+++ b/UnitaryTests/SCard_fork.py
@@ -20,6 +20,7 @@
 # #define DO_CHECK_SAME_PROCESS
 # or this unitary test will fail
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import time
@@ -33,10 +34,10 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
     SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY)
@@ -52,20 +53,21 @@ if pid == 0:
 
     # expected value
     if hresult == SCARD_E_INVALID_HANDLE:
-        print "test passed"
+        print("test passed")
     elif hresult != SCARD_S_SUCCESS:
         raise ListReadersException(hresult)
     else:
-        print "test FAILED got %s. SCARD_E_INVALID_HANDLE was expected" % SCardGetErrorMessage(hresult)
-        print
+        print("test FAILED got %s. SCARD_E_INVALID_HANDLE was expected"
+                % SCardGetErrorMessage(hresult))
+        print()
 
         hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
-        print "son: SCardDisconnect()", SCardGetErrorMessage(hresult)
+        print("son: SCardDisconnect()", SCardGetErrorMessage(hresult))
         if hresult != SCARD_S_SUCCESS:
             raise BaseSCardException(hresult)
 
         hresult = SCardReleaseContext(hcontext)
-        print "son: SCardReleaseContext()", SCardGetErrorMessage(hresult)
+        print("son: SCardReleaseContext()", SCardGetErrorMessage(hresult))
         if hresult != SCARD_S_SUCCESS:
             raise ReleaseContextException(hresult)
 
@@ -75,14 +77,15 @@ else:
     # give some time to the son
     time.sleep(1)
 
-    print "father: SCardDisconnect..."
+    print("father: SCardDisconnect...")
     hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
-    print "father: SCardDisconnect()", SCardGetErrorMessage(hresult)
+    print("father: SCardDisconnect()", SCardGetErrorMessage(hresult))
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
 
-    print "father: SCardReleaseContext..."
+    print("father: SCardReleaseContext...")
     hresult = SCardReleaseContext(hcontext)
-    print "father: SCardReleaseContext()", SCardGetErrorMessage(hresult)
+    print("father: SCardReleaseContext()",
+            SCardGetErrorMessage(hresult))
     if hresult != SCARD_S_SUCCESS:
         raise ReleaseContextException(hresult)
diff --git a/UnitaryTests/ThreadSafe.py b/UnitaryTests/ThreadSafe.py
index e7d4525..8267e3c 100755
--- a/UnitaryTests/ThreadSafe.py
+++ b/UnitaryTests/ThreadSafe.py
@@ -19,6 +19,7 @@
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
 
+from __future__ import print_function
 from smartcard.scard import (SCardEstablishContext, SCardReleaseContext,
     SCardGetErrorMessage, SCARD_SCOPE_USER, SCARD_S_SUCCESS)
 from smartcard.pcsc.PCSCExceptions import *
@@ -34,13 +35,13 @@ def stress(*args):
     """
     thread = args[0]
     for j in range(0, MAX_ITER):
-        print thread,
+        print(thread, end=' ')
         hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
         if hresult != SCARD_S_SUCCESS:
             raise EstablishContextException(hresult)
 
         hresult = SCardReleaseContext(hcontext)
-        #print "SCardReleaseContext()", SCardGetErrorMessage(hresult)
+        #print("SCardReleaseContext()", SCardGetErrorMessage(hresult))
         if hresult != SCARD_S_SUCCESS:
             raise ReleaseContextException(hresult)
 
@@ -55,7 +56,7 @@ def main():
     for i in range(0, MAX_THREADS):
         thread = threading.Thread(target=stress, args=(i,))
         threads.append(thread)
-        print "start thread", i
+        print("start thread", i)
         thread.start()
 
     for thread in threads:
diff --git a/UnitaryTests/ThreadSafeConnect.py b/UnitaryTests/ThreadSafeConnect.py
index 7eb749a..c001166 100755
--- a/UnitaryTests/ThreadSafeConnect.py
+++ b/UnitaryTests/ThreadSafeConnect.py
@@ -20,6 +20,7 @@
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
 
+from __future__ import print_function
 from smartcard.scard import (SCardEstablishContext, SCardReleaseContext,
     SCardListReaders, SCardConnect, SCardDisconnect,
     SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY, SCARD_LEAVE_CARD,
@@ -36,7 +37,7 @@ def stress(*args):
     stress method
     """
     thread = args[0]
-    print "Starting thread:", thread
+    print("Starting thread:", thread)
 
     hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
     if hresult != SCARD_S_SUCCESS:
@@ -54,19 +55,19 @@ def stress(*args):
             raise BaseSCardException(hresult)
 
         log = "%d:%d" % (thread, j)
-        print log,
+        print(log, end=' ')
 
         hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
         if hresult != SCARD_S_SUCCESS:
             raise BaseSCardException(hresult)
 
-    print
+    print()
 
     hresult = SCardReleaseContext(hcontext)
     if hresult != SCARD_S_SUCCESS:
         raise ReleaseContextException(hresult)
 
-    print "Exiting thread:", thread
+    print("Exiting thread:", thread)
 
 def main():
     """
@@ -81,11 +82,11 @@ def main():
         thread.start()
 
     for thread in threads:
-        print "joining:", thread.getName(),
+        print("joining:", thread.getName(), end=' ')
         thread.join()
-        print "joined:", thread.getName()
+        print("joined:", thread.getName())
 
-    print "Exiting main"
+    print("Exiting main")
 
 if __name__ == "__main__":
     main()
diff --git a/UnitaryTests/control_get_firmware.py b/UnitaryTests/control_get_firmware.py
index 27b6ef6..c0bb393 100755
--- a/UnitaryTests/control_get_firmware.py
+++ b/UnitaryTests/control_get_firmware.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT,
     SCARD_LEAVE_CARD, SCARD_CTL_CODE, getTlvProperties)
@@ -27,7 +28,7 @@ for reader in readers():
     cardConnection.connect(mode=SCARD_SHARE_DIRECT,
         disposition=SCARD_LEAVE_CARD)
 
-    print "Reader:", reader
+    print("Reader:", reader)
 
     # properties returned by IOCTL_FEATURE_GET_TLV_PROPERTIES
     properties = getTlvProperties(cardConnection)
@@ -40,14 +41,14 @@ for reader in readers():
             IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1)
             res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
                 get_firmware)
-            print " Firmware:", "".join([chr(x) for x in res])
+            print(" Firmware:", "".join([chr(x) for x in res]))
         else:
-            print " Not a Gemalto reader"
+            print(" Not a Gemalto reader")
             key = 'PCSCv2_PART10_PROPERTY_sFirmwareID'
             if key in properties:
                 firmware = properties[key]
-                print " Firmware:", firmware
+                print(" Firmware:", firmware)
             else:
-                print " %s not supported" % key
+                print(" %s not supported" % key)
     else:
-        print " %s not supported" % key
+        print(" %s not supported" % key)
diff --git a/UnitaryTests/control_switch_interface.py b/UnitaryTests/control_switch_interface.py
index 61d79d7..0eb51f3 100755
--- a/UnitaryTests/control_switch_interface.py
+++ b/UnitaryTests/control_switch_interface.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT,
     SCARD_LEAVE_CARD, SCARD_CTL_CODE)
@@ -34,24 +35,24 @@ def switch_interface(interface):
         cardConnection.connect(mode=SCARD_SHARE_DIRECT, disposition=SCARD_LEAVE_CARD)
 
         switch_interface_cmd = [0x52, 0xF8, 0x04, 0x01, 0x00, interface]
-        print "Reader:", reader, "=>",
+        print("Reader:", reader, "=>", end=' ')
         try:
             res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
                 switch_interface_cmd)
         except:
-            print "FAILED"
+            print("FAILED")
         else:
             if res != [0, 0, 0, 0]:
-                print "Failed: ",
+                print("Failed: ", end='')
                 err = res[0] * 256 + res[1]
                 if err == 0xFF83:
-                    print "Wrong data parameters"
+                    print("Wrong data parameters")
                 elif err == 0xFF84:
-                    print "Wrong command bytes"
+                    print("Wrong command bytes")
                 else:
-                    print "Unknown error:", [hex(x) for x in res]
+                    print("Unknown error:", [hex(x) for x in res])
             else:
-                print "Success"
+                print("Success")
 
 if __name__ == "__main__":
     import sys
diff --git a/UnitaryTests/getAttrib.py b/UnitaryTests/getAttrib.py
index a593c45..4672aef 100755
--- a/UnitaryTests/getAttrib.py
+++ b/UnitaryTests/getAttrib.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.scard import (SCARD_ATTR_VENDOR_NAME, SCARD_SHARE_DIRECT,
     SCARD_LEAVE_CARD, SCARD_ATTR_DEVICE_FRIENDLY_NAME,
@@ -34,26 +35,27 @@ def main():
     try:
         # Vendor name
         name = card_connection.getAttrib(SCARD_ATTR_VENDOR_NAME)
-        print ''.join([chr(char) for char in name])
+        print(''.join([chr(char) for char in name]))
 
         # Vendor-supplied interface device version (DWORD in the form
         # 0xMMmmbbbb where MM = major version, mm = minor version, and
         # bbbb = build number).
         version = card_connection.getAttrib(SCARD_ATTR_VENDOR_IFD_VERSION)
-        print "Version: %d.%d.%d" % (version[3], version[2], version[0])
+        print("Version: %d.%d.%d" % (version[3], version[2],
+                version[0]))
 
         # Vendor-supplied interface device serial number.
         # only for readers with a USB serial number
         serial = card_connection.getAttrib(SCARD_ATTR_VENDOR_IFD_SERIAL_NO)
-        print serial
+        print(serial)
 
         # Reader's display name
         # only with pcsc-lite version >= 1.6.0
         name = card_connection.getAttrib(SCARD_ATTR_DEVICE_FRIENDLY_NAME)
-        print ''.join([chr(char) for char in name])
+        print(''.join([chr(char) for char in name]))
 
     except smartcard.Exceptions.SmartcardException, message:
-        print "Exception:", message
+        print("Exception:", message)
 
 if __name__ == "__main__":
     main()
diff --git a/UnitaryTests/reset_card.py b/UnitaryTests/reset_card.py
index 2f54269..b70354b 100755
--- a/UnitaryTests/reset_card.py
+++ b/UnitaryTests/reset_card.py
@@ -16,6 +16,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.scard import *
 from smartcard.pcsc.PCSCExceptions import *
 import sys
@@ -27,10 +28,10 @@ if hresult != SCARD_S_SUCCESS:
 hresult, readers = SCardListReaders(hcontext, [])
 if hresult != SCARD_S_SUCCESS:
     raise ListReadersException(hresult)
-print 'PC/SC Readers:', readers
+print('PC/SC Readers:', readers)
 
 reader = readers[0]
-print "Using reader:", reader
+print("Using reader:", reader)
 
 # Connect in SCARD_SHARE_SHARED mode
 hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
@@ -39,7 +40,7 @@ if hresult != SCARD_S_SUCCESS:
     raise BaseSCardException(hresult)
 
 if len(sys.argv) > 1:
-    print "reset using SCardReconnect"
+    print("reset using SCardReconnect")
 
     # Reconnect after reset
     hresult, dwActiveProtocol = SCardReconnect(hcard,
@@ -47,7 +48,7 @@ if len(sys.argv) > 1:
     if hresult != SCARD_S_SUCCESS:
         raise BaseSCardException(hresult)
 else:
-    print "reset using SCardDisconnect"
+    print("reset using SCardDisconnect")
 
     # Disconnect after reset
     hresult = SCardDisconnect(hcard, SCARD_RESET_CARD)
diff --git a/UnitaryTests/stress_apdu.py b/UnitaryTests/stress_apdu.py
index 0a8c6e7..2077ab3 100755
--- a/UnitaryTests/stress_apdu.py
+++ b/UnitaryTests/stress_apdu.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from time import time, ctime
 
@@ -32,17 +33,17 @@ def stress(reader):
     connection.connect()
 
     data, sw1, sw2 = connection.transmit(SELECT)
-    print data
-    print "Select Applet: %02X %02X" % (sw1, sw2)
+    print(data)
+    print("Select Applet: %02X %02X" % (sw1, sw2))
 
     i = 0
     while True:
         before = time()
         data, sw1, sw2 = connection.transmit(COMMAND)
         after = time()
-        print data
+        print(data)
         delta = after - before
-        print "%d Command: %02X %02X, delta: %f" % (i, sw1, sw2, delta)
+        print("%d Command: %02X %02X, delta: %f" % (i, sw1, sw2, delta))
         if delta > 1:
             sys.stderr.write(ctime() + " %f\n" % delta)
         i += 1
@@ -52,10 +53,10 @@ if __name__ == "__main__":
 
     # get all the available readers
     readers = readers()
-    print "Available readers:"
+    print("Available readers:")
     i = 0
     for r in readers:
-        print "%d: %s" % (i, r)
+        print("%d: %s" % (i, r))
         i += 1
 
     try:
@@ -64,6 +65,6 @@ if __name__ == "__main__":
         i = 0
 
     reader = readers[i]
-    print "Using:", reader
+    print("Using:", reader)
 
     stress(reader)
diff --git a/UnitaryTests/stress_get_firmware.py b/UnitaryTests/stress_get_firmware.py
index 44bef4d..1cc6ecb 100755
--- a/UnitaryTests/stress_get_firmware.py
+++ b/UnitaryTests/stress_get_firmware.py
@@ -18,6 +18,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import readers
 from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT,
     SCARD_LEAVE_CARD, SCARD_CTL_CODE)
@@ -38,8 +39,8 @@ def stress(reader):
             get_firmware)
         after = time()
         delta = after - before
-        print "%d Reader: %s, delta: %d" % (i, reader, delta)
-        print "Firmware:", "".join([chr(x) for x in res])
+        print("%d Reader: %s, delta: %d" % (i, reader, delta))
+        print("Firmware:", "".join([chr(x) for x in res]))
         if delta > 1:
             sys.stderr.write(ctime() + " %f\n" % delta)
         i += 1
@@ -49,10 +50,10 @@ if __name__ == "__main__":
 
     # get all the available readers
     readers = readers()
-    print "Available readers:"
+    print("Available readers:")
     i = 0
     for r in readers:
-        print "%d: %s" % (i, r)
+        print("%d: %s" % (i, r))
         i += 1
 
     try:
@@ -61,6 +62,6 @@ if __name__ == "__main__":
         i = 0
 
     reader = readers[i]
-    print "Using:", reader
+    print("Using:", reader)
 
     stress(reader)
diff --git a/UnitaryTests/transmit_loop.py b/UnitaryTests/transmit_loop.py
index ee0b578..4e03bb0 100755
--- a/UnitaryTests/transmit_loop.py
+++ b/UnitaryTests/transmit_loop.py
@@ -16,6 +16,7 @@
 #   You should have received a copy of the GNU General Public License along
 #   with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 from smartcard.System import *
 from smartcard.CardConnection import *
 
@@ -26,10 +27,10 @@ connection.connect()
 SELECT = [0x00, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00]
 i = 0
 while 1:
-    print "loop:", i
+    print("loop:", i)
     i += 1
     data, sw1, sw2 = connection.transmit(SELECT)
-    print data
-    print "%02x %02x" % (sw1, sw2)
+    print(data)
+    print("%02x %02x" % (sw1, sw2))
 
 connection.disconnect()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/PCSC.git



More information about the Pcsclite-cvs-commit mailing list