f



Error: UnboundLocalError: local variable 'PfFlag' referenced before assignment

$$ TestCase ID : 001
Step : deleteDvc,206268
Result Eval type : XmlChk
Step : deleteDvc,206269
Result Eval type : XmlChk
Traceback (most recent call last):
  File "C:\UDR2\UDRxmlGateway.py", line 388, in <module>
    ParseAll()
  File "C:\UDR2\UDRxmlGateway.py", line 371, in ParseAll
    if (PfFlag =3D=3D 1):
UnboundLocalError: local variable 'PfFlag' referenced before assignment
=20
=20
PfFlag gets assigned in a for loop in line 365
        for i in range(PfFlagArrSize):
            if (PfFlagArr[i] =3D=3D 1):
--->         PfFlag =3D int(1)
                break
            else:
                PfFlag =3D int(-1)

No idea what is going on here
=20
Harry C. Wang
Sr. Test Engineer (Automation)
Phone 206 - 268 - 7502
temporary e-mail: hwang@ciber.com=20
Personal e-mail: hcwang@comcast.net=20
Ciber EmpID # 36219
0
HWang5876 (6)
11/30/2007 11:07:42 PM
comp.lang.python 77058 articles. 3 followers. Post Follow

2 Replies
270 Views

Similar Articles

[PageSpeed] 22

On Nov 30, 3:07 pm, "Wang, Harry" <HW...@ciber.com> wrote:
> $$ TestCase ID : 001
> Step : deleteDvc,206268
> Result Eval type : XmlChk
> Step : deleteDvc,206269
> Result Eval type : XmlChk
> Traceback (most recent call last):
>   File "C:\UDR2\UDRxmlGateway.py", line 388, in <module>
>     ParseAll()
>   File "C:\UDR2\UDRxmlGateway.py", line 371, in ParseAll
>     if (PfFlag == 1):
> UnboundLocalError: local variable 'PfFlag' referenced before assignment
>
> PfFlag gets assigned in a for loop in line 365
>         for i in range(PfFlagArrSize):
>             if (PfFlagArr[i] == 1):
> --->         PfFlag = int(1)
>                 break
>             else:
>                 PfFlag = int(-1)
>
> No idea what is going on here
>
> Harry C. Wang
> Sr. Test Engineer (Automation)
> Phone 206 - 268 - 7502
> temporary e-mail: hw...@ciber.com
> Personal e-mail: hcw...@comcast.net
> Ciber EmpID # 36219

OK this problem has been solved.  Duh???  The variable thingy is not
initialized.
0
hcwang (1)
12/1/2007 1:33:21 AM
Calvin wrote:
> On Nov 30, 3:07 pm, "Wang, Harry" <HW...@ciber.com> wrote:
> > $$ TestCase ID : 001
> > Step : deleteDvc,206268
> > Result Eval type : XmlChk
> > Step : deleteDvc,206269
> > Result Eval type : XmlChk
> > Traceback (most recent call last):
> >   File "C:\UDR2\UDRxmlGateway.py", line 388, in <module>
> >     ParseAll()
> >   File "C:\UDR2\UDRxmlGateway.py", line 371, in ParseAll
> >     if (PfFlag == 1):
> > UnboundLocalError: local variable 'PfFlag' referenced before assignment
> >
> > PfFlag gets assigned in a for loop in line 365
> >         for i in range(PfFlagArrSize):
> >             if (PfFlagArr[i] == 1):
> > --->         PfFlag = int(1)
> >                 break
> >             else:
> >                 PfFlag = int(-1)
> >
> > No idea what is going on here
> >
> > Harry C. Wang
> > Sr. Test Engineer (Automation)
> > Phone 206 - 268 - 7502
> > temporary e-mail: hw...@ciber.com
> > Personal e-mail: hcw...@comcast.net
> > Ciber EmpID # 36219
>
> OK this problem has been solved.  Duh???  The variable thingy is not
> initialized.

Well, that much is obvious.  What's probably not so obvious is *why*
the "variable thingy" is not initialized.  From what I can tell, this
could only happen if, and only if, PfFlagArrSize <= 0.  In that case,
the body of the for loop will never execute and PfFlag will *not* be
set, hence the error.

--Nathan Davis
0
12/1/2007 6:13:57 PM
Reply: