Change in osmo-sim-auth[master]: utils: add support of Python 3 for stringToByte()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Ludovic Rousseau gerrit-no-reply at lists.osmocom.org
Sun Oct 25 13:36:54 UTC 2020


Ludovic Rousseau has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sim-auth/+/20905 )


Change subject: utils: add support of Python 3 for stringToByte()
......................................................................

utils: add support of Python 3 for stringToByte()

Use a special case for Python 2.

Change-Id: I2ac97ff85bde5584fbe82880b3360c97d4cd54c1
---
M card/utils.py
1 file changed, 6 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sim-auth refs/changes/05/20905/1

diff --git a/card/utils.py b/card/utils.py
index 3c1b1f1..e3777d7 100644
--- a/card/utils.py
+++ b/card/utils.py
@@ -24,6 +24,7 @@
 
 from collections import deque
 from smartcard.util import toBytes
+import sys
 
 # from python 2.6, format('b') allows to use 0b10010110 notation: 
 # much convinient
@@ -50,7 +51,11 @@
     '''
     bytelist = []
     for c in string:
-        bytelist.extend( toBytes(c.encode('hex')) )
+        if sys.version_info[0] < 3:
+            # Python 2
+            bytelist.extend( toBytes(c.encode('hex')) )
+        else:
+            bytelist.append(c)
     return bytelist
 
 # equivalent to the pyscard function "toASCIIString"

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sim-auth/+/20905
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sim-auth
Gerrit-Branch: master
Gerrit-Change-Id: I2ac97ff85bde5584fbe82880b3360c97d4cd54c1
Gerrit-Change-Number: 20905
Gerrit-PatchSet: 1
Gerrit-Owner: Ludovic Rousseau <ludovic.rousseau+osmocom at free.fr>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201025/c18d64e6/attachment.htm>


More information about the gerrit-log mailing list