laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/36901?usp=email )

Change subject: euicc.py: Resolve possible variable use before assignment
......................................................................

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(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




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 https://gerrit.osmocom.org/c/pysim/+/36901?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifdf4651e503bae6ea3e91c89c2121b416a12fb1a
Gerrit-Change-Number: 36901
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to