[Python-au] strange pre-acting bug

Garry Trethewey garrytre at bigpond.com
Tue May 18 21:22:17 UTC 2010


Hello.
I've just joined this list because I've got a bug that I can't 
understand. AFAIK it shouldn't be able to happen, and I hope someone can 
enlighten me. I don't even know what to call it to google it.

Briefely, if I comment out a line, a line _before_ it works, if I enable 
the line, the line before it doesn't work.


212  print 'vPage = ', vPage
213  raw_input('press enter')
124  '''
125  if vPage.isdigit():
126    vPage = str(int(vPage) + 1)
217    '''
218  print 'vPage = ', vPage
219  raw_input('press enter')


vPage =
press enter
vPage =
press enter


but if I uncomment 214 - 217

212  print 'vPage = ', vPage
213  raw_input('press enter')
124
125  if vPage.isdigit():
126    vPage = str(int(vPage) + 1)
217
218  print 'vPage = ', vPage
219  raw_input('press enter')


vPage =
Traceback (most recent call last):
   File "/home/garry/Desktop/bimbo/script/buggy_intact/get_scan02.py", 
line 381, in <module>
     vPage =fn_get_page_num()
   File "/home/garry/Desktop/bimbo/script/buggy_intact/get_scan02.py", 
line 212, in fn_get_page_num
     print 'vPage = ', vPage
UnboundLocalError: local variable 'vPage' referenced before assignment


While I'm sure I could find a workaround for this instance, I'm more 
interested in the fact that as far as I can se, this bug should be 
impossible.

Python 2.5.2 (r252:60911, Jan 20 2010, 21:48:48)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2

Ubuntu 8.04

I'm happy to provide all my code. The whole project is < 1000 lines plus 
  easygui.py from http://easygui.sourceforge.net/ if anybody wants a look.



regards
------------------------------------
Garry Trethewey
------------------------------------





More information about the python-au mailing list