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/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/17280 ) Change subject: commands: Python 3 fix: properly distinguish str and list ...................................................................... commands: Python 3 fix: properly distinguish str and list Unlike Python 2, in Python 3 strings also have attribute '__iter__'. Because of that, a string could be passed to select_file(), that actually expects a list as the first parameter. P.S. Madness, Python 3 is just a new different language... P.P.S. They should have renamed it not to confuse people. Change-Id: I92af47abb6adff0271c55e7f278e8c5188f2be75 Fixes: OS#4419 --- M pySim/commands.py 1 file changed, 2 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/80/17280/1 diff --git a/pySim/commands.py b/pySim/commands.py index ff64ed2..cc7acc6 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -102,6 +102,8 @@ def select_file(self, dir_list): rv = [] + if type(dir_list) is not list: + dir_list = [dir_list] for i in dir_list: data, sw = self._tp.send_apdu_checksw(self.cla_byte + "a4" + self.sel_ctrl + "02" + i) rv.append(data) @@ -112,8 +114,6 @@ return self._tp.send_apdu_checksw(self.cla_byte + "a4" + "0404" + aidlen + aid) def read_binary(self, ef, length=None, offset=0): - if not hasattr(type(ef), '__iter__'): - ef = [ef] r = self.select_file(ef) if len(r[-1]) == 0: return (None, None) @@ -123,23 +123,17 @@ return self._tp.send_apdu(pdu) def update_binary(self, ef, data, offset=0): - if not hasattr(type(ef), '__iter__'): - ef = [ef] self.select_file(ef) pdu = self.cla_byte + 'd6%04x%02x' % (offset, len(data) // 2) + data return self._tp.send_apdu_checksw(pdu) def read_record(self, ef, rec_no): - if not hasattr(type(ef), '__iter__'): - ef = [ef] r = self.select_file(ef) rec_length = self.__record_len(r) pdu = self.cla_byte + 'b2%02x04%02x' % (rec_no, rec_length) return self._tp.send_apdu(pdu) def update_record(self, ef, rec_no, data, force_len=False): - if not hasattr(type(ef), '__iter__'): - ef = [ef] r = self.select_file(ef) if not force_len: rec_length = self.__record_len(r) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/17280 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I92af47abb6adff0271c55e7f278e8c5188f2be75 Gerrit-Change-Number: 17280 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200226/16c84ab5/attachment.htm>