I am stuck at the a small code as the following:
This is module main, the main entry of the application :
The class cchatter is coded in a module called irc_chatter_mod ; and its constructor looks like this :
Problem :
The compiler outputs :
File "C:\public\proj ects\py\AmeL\ir c_chatter_mod_u nit_test.py", line 41, in <module>
main()
File "C:\public\proj ects\py\AmeL\ir c_chatter_mod_u nit_test.py", line 18, in main
chatter = cchatter("nickn ame", "username", "fullname", 1)
File "C:\public\proj ects\py\AmeL\ir c_chatter_mod.p y", line 55, in __init__
del curFrame
UnboundLocalErr or: 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 ?
This is module main, the main entry of the application :
Code:
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 .....
Code:
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......
The compiler outputs :
File "C:\public\proj ects\py\AmeL\ir c_chatter_mod_u nit_test.py", line 41, in <module>
main()
File "C:\public\proj ects\py\AmeL\ir c_chatter_mod_u nit_test.py", line 18, in main
chatter = cchatter("nickn ame", "username", "fullname", 1)
File "C:\public\proj ects\py\AmeL\ir c_chatter_mod.p y", line 55, in __init__
del curFrame
UnboundLocalErr or: 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 ?
Comment