Change in pysim[master]: utils: fix list comprehension in h2s(): ignore upper case padding

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/.

fixeria gerrit-no-reply at lists.osmocom.org
Sat May 9 20:13:54 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/18172 )


Change subject: utils: fix list comprehension in h2s(): ignore upper case padding
......................................................................

utils: fix list comprehension in h2s(): ignore upper case padding

By definition, h2s() is supposed to skip padding in the given
hexstring, so it was working fine for 'ff', but not for 'FF'.

Change-Id: I2c5d72a0f7f2796115116737f9f7b5299021f6a3
Signed-off-by: Vadim Yanitskiy <axilirator at gmail.com>
---
M pySim/utils.py
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/72/18172/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 1980685..6c4bee0 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -35,7 +35,8 @@
 	return ''.join(['%02x'%(x) for x in s])
 
 def h2s(s):
-	return ''.join([chr((int(x,16)<<4)+int(y,16)) for x,y in zip(s[0::2], s[1::2]) if not (x == 'f' and y == 'f') ])
+	return ''.join([chr((int(x,16)<<4)+int(y,16)) for x,y in zip(s[0::2], s[1::2])
+						      if int(x + y, 16) != 0xff])
 
 def s2h(s):
 	return b2h(s)

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/18172
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2c5d72a0f7f2796115116737f9f7b5299021f6a3
Gerrit-Change-Number: 18172
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200509/93e9d4f8/attachment.htm>


More information about the gerrit-log mailing list