laforge submitted this change.
euicc.py: Resolve possible variable use before assignment
pySim/euicc.py:436:31: E0606: Possibly using variable 'p_id' before assignment (possibly-used-before-assignment)
pySim/euicc.py:455:31: E0606: Possibly using variable 'p_id' before assignment (possibly-used-before-assignment)
pySim/euicc.py:473:31: E0606: Possibly using variable 'p_id' before assignment (possibly-used-before-assignment)
Let's raise an exception in the erroneous case.
Change-Id: Ifdf4651e503bae6ea3e91c89c2121b416a12fb1a
---
M pySim/euicc.py
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/pySim/euicc.py b/pySim/euicc.py
index c27c91f..7f4cdda 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -429,8 +429,11 @@
"""Perform an ES10c EnableProfile function."""
if opts.isdp_aid:
p_id = ProfileIdentifier(children=[IsdpAid(decoded=opts.isdp_aid)])
- if opts.iccid:
+ elif opts.iccid:
p_id = ProfileIdentifier(children=[Iccid(decoded=opts.iccid)])
+ else:
+ # this is guaranteed by argparse; but we need this to make pylint happy
+ raise ValueError('Either ISD-P AID or ICCID must be given')
ep_cmd_contents = [p_id, RefreshFlag(decoded=opts.refresh_required)]
ep_cmd = EnableProfileReq(children=ep_cmd_contents)
ep = CardApplicationISDR.store_data_tlv(self._cmd.lchan.scc, ep_cmd, EnableProfileResp)
@@ -448,8 +451,11 @@
"""Perform an ES10c DisableProfile function."""
if opts.isdp_aid:
p_id = ProfileIdentifier(children=[IsdpAid(decoded=opts.isdp_aid)])
- if opts.iccid:
+ elif opts.iccid:
p_id = ProfileIdentifier(children=[Iccid(decoded=opts.iccid)])
+ else:
+ # this is guaranteed by argparse; but we need this to make pylint happy
+ raise ValueError('Either ISD-P AID or ICCID must be given')
dp_cmd_contents = [p_id, RefreshFlag(decoded=opts.refresh_required)]
dp_cmd = DisableProfileReq(children=dp_cmd_contents)
dp = CardApplicationISDR.store_data_tlv(self._cmd.lchan.scc, dp_cmd, DisableProfileResp)
@@ -466,8 +472,11 @@
"""Perform an ES10c DeleteProfile function."""
if opts.isdp_aid:
p_id = IsdpAid(decoded=opts.isdp_aid)
- if opts.iccid:
+ elif opts.iccid:
p_id = Iccid(decoded=opts.iccid)
+ else:
+ # this is guaranteed by argparse; but we need this to make pylint happy
+ raise ValueError('Either ISD-P AID or ICCID must be given')
dp_cmd_contents = [p_id]
dp_cmd = DeleteProfileReq(children=dp_cmd_contents)
dp = CardApplicationISDR.store_data_tlv(self._cmd.lchan.scc, dp_cmd, DeleteProfileResp)
To view, visit change 36901. To unsubscribe, or for help writing mail filters, visit settings.