Error: UnboundLocalError: local variable 'PfFlag' referenced beforeassignment

W

Wang, Harry

$$ 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 == 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: (e-mail address removed)
Personal e-mail: (e-mail address removed)
Ciber EmpID # 36219
 
C

Calvin

$$ 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 == 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: (e-mail address removed)
Personal e-mail: (e-mail address removed)
Ciber EmpID # 36219


OK this problem has been solved. Duh??? The variable thingy is not
initialized.
 
D

davisn90210

Calvin said:
$$ 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 == 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: (e-mail address removed)
Personal e-mail: (e-mail address removed)
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top