[NumPy-Tickets] [NumPy] #1932: f2py crashes with UnboundLocalError exception

NumPy Trac numpy-tickets@scipy....
Wed Aug 29 08:55:03 CDT 2012


#1932: f2py crashes with UnboundLocalError exception
------------------------+---------------------------------------------------
 Reporter:  josdekloe   |       Owner:  pearu      
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  Unscheduled
Component:  numpy.f2py  |     Version:  1.6.2      
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by josdekloe):

 Sorry, the wikiformatting seems to have garbled my previous message. Here
 is a next try:

 The same problem still is present in f2py version 1.6.2 as currently
 shipped by Fedora17.
 After some debugging I found that the code

 {{{
     exec('c = isintent_%s(var)' % intent)

 }}}
 in file:
   /usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py
 does not work as intended on my python3 version (version  3.2.3).

 In function true_intent_list this code:


 {{{
         try:
             exec('c = isintent_%s(var)' % intent)
         except NameError:
             c = 0


 }}}
 does not always work as intended, and on my system it does not define a
 variable 'c' in the local scope of this function.
 In stead the correct code should be:


 {{{
         try:
             ldict = locals()
             exec('c = isintent_%s(var)' % intent,globals(),ldict)
             c = ldict['c']
         except NameError:
             c = 0


 }}}
 This type of problem has been reported and discussed before, for example
 here:
   http://stackoverflow.com/questions/1463306/how-does-exec-work-with-
 locals
 and here:
   http://bugs.python.org/issue4831

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1932#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list