[Scipy-tickets] [SciPy] #1576: Attempt to access func_name attribute in fsolve in python 3

SciPy Trac scipy-tickets@scipy....
Mon Dec 19 16:13:41 CST 2011


#1576: Attempt to access func_name attribute in fsolve in python 3
----------------------------+-----------------------------------------------
 Reporter:  sanders         |       Owner:  somebody   
     Type:  defect          |      Status:  new        
 Priority:  normal          |   Milestone:  Unscheduled
Component:  scipy.optimize  |     Version:  devel      
 Keywords:  fsolve          |  
----------------------------+-----------------------------------------------
 I am using the repo versions of numpy and scipy in python 3.2.2.  When the
 function passed to fsolve raises an exception, the code {{{fsolve}}} uses
 to deal with this apparently tries to access the {{{func_name}}} attribute
 (which is renamed to {{{__name__}}} in python 3), causing an
 {{{AttributeError}}} - I can't find the source of the problem - I assume
 it is in some C code?  If I give the function a {{{func_name}}} attribute
 before passing it to {{{fsolve}}}, there is a segfault.  The following
 python session shows both issues

 {{{
 Python 3.2.2 (default, Dec 19 2011, 21:40:53)
 [GCC 4.6.1] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> from scipy.optimize import fsolve
 >>> from math import sqrt
 >>> def f(x):
 ...     return sqrt(x)
 ...
 >>> fsolve(f,1.0)
 Traceback (most recent call last):
   File "<stdin>", line 2, in f
 ValueError: math domain error
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/james/Desktop/python3/newscipy/build/lib/python3.2/site-
 packages/scipy/optimize/minpack.py", line 125, in fsolve
     maxfev, ml, mu, epsfcn, factor, diag)
 AttributeError: 'function' object has no attribute 'func_name'
 >>> f.func_name = __name__
 >>> fsolve(f,1.0)
 Traceback (most recent call last):
   File "<stdin>", line 2, in f
 ValueError: math domain error
 Segmentation fault
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1576>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list