fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/26055 )

Change subject: commands: do not check SW manually, use send_apdu_checksw()
......................................................................


Patch Set 2: Code-Review+1

(2 comments)

https://gerrit.osmocom.org/c/pysim/+/26055/2/pySim/commands.py
File pySim/commands.py:

https://gerrit.osmocom.org/c/pysim/+/26055/2/pySim/commands.py@148
PS2, Line 148:                  data, sw = self._tp.send_apdu_checksw(pdu)
I would wrap this block into additional try/catch:

  try:
    data, sw = self._tp.send_apdu_checksw(pdu)
    total_data += data
    chunk_offset += chunk_len
  except Exception as e:
    raise ValueError('Failed to read (offset %d)' % (offset)) from e

Note 'from e' in the last line. This way, if send_apdu_checksw() raises an 
exception, it would get equipped with the contextual information. See 
https://docs.python.org/3/tutorial/errors.html#exception-chaining.


https://gerrit.osmocom.org/c/pysim/+/26055/2/pySim/commands.py@177
PS2, Line 177:                  chunk_data, chunk_sw = 
self._tp.send_apdu_checksw(pdu)
Same here.



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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I9ce556ac0b7bb21c5c5a27170c32af0152255b79
Gerrit-Change-Number: 26055
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillm...@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Comment-Date: Mon, 01 Nov 2021 18:29:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Reply via email to