I am stuck at the a small code as the following:
This is module main, the main entry of the application :
-
from irc_log_mod import *
-
from irc_chatter_mod import *
-
from inspect import *
-
from irc_global_mod import *
-
-
def main():
-
try:
-
curFrame = currentframe()
-
writeLog(LOG,
-
curFrame.f_code.co_filename,
-
"",
-
"main()",
-
curFrame.f_lineno,
-
DBG_LEVEL_ONE,
-
"FUNCTION ENTRY")
-
finally:
-
del curFrame
-
-
# problem comes in this line
-
chatter = cchatter("nickname", "username", "fullname", 1)
-
-
# ... rest of the code .....
-
The class cchatter is coded in a module called irc_chatter_mod; and its constructor looks like this :
-
def __init__(self, nickname, username, fullname, flag):
-
-
# cchatter::__init__ : BEGIN
-
-
# FUNCTION ENTRY
-
-
try:
-
curFrame = currentframe()
-
writeLog(LOG,
-
curFrame.f_code.co_filename,
-
"cchatter",
-
"__init__",
-
curFrame.f_lineno,
-
DBG_LEVEL_THREE,
-
"FUNCTION ENTRY")
-
finally:
-
# The problem is here
-
del curFrame
-
-
# ...rest of the codes......
-
-
Problem :
The compiler outputs :
File "C:\public\projects\py\AmeL\irc_chatter_mod_unit_t est.py", line 41, in <module>
main()
File "C:\public\projects\py\AmeL\irc_chatter_mod_unit_t est.py", line 18, in main
chatter = cchatter("nickname", "username", "fullname", 1)
File "C:\public\projects\py\AmeL\irc_chatter_mod.py ", line 55, in __init__
del curFrame
UnboundLocalError: local variable 'curFrame' referenced before assignment
From my point of view, this error message should be thrown when a variable is referenced, or used, before it is assigned by any value. I found nothing go wrong with my code.
Could you guys please help me ?