#15184: CachedFunction file location seems problematic
----------------------+-----------------------------
   Reporter:  nbruin  |            Owner:
       Type:  defect  |           Status:  new
   Priority:  major   |        Milestone:  sage-5.12
  Component:  misc    |         Keywords:
  Merged in:          |          Authors:
  Reviewers:          |  Report Upstream:  N/A
Work issues:          |           Branch:
     Commit:          |     Dependencies:
   Stopgaps:          |
----------------------+-----------------------------
 There is a problem where cached function report problematic file
 information. Consider
 {{{
 sage: M=IntegerModRing(7)
 sage: edit(M.is_finite) #no problem
 sage: edit(M.is_field)
 IOError: [Errno 2] No such file or directory:
 '/sage/rings/finite_rings/integer_mod_ring.py'
 }}}
 Indeed sage doesn't find the appropriate source file:
 {{{
 sage: from sage.misc.sageinspect import sage_getfile
 sage: sage_getfile(M.is_finite)
 '/usr/local/sage/5.10/local/lib/python2.7/site-
 packages/sage/rings/finite_rings/integer_mod_ring.py'
 sage: sage_getfile(M.is_field)
 '/sage/rings/finite_rings/integer_mod_ring.py'
 }}}
 The code that makes this happen is `sage/misc/cachefunc.pyx`, line 621:
 {{{#!python
             if sourcelines is not None:
                 from sage.env import SAGE_SRC, SAGE_LIB
                 filename = sage_getfile(f)
                 # The following is a heuristics to get
                 # the file name of the cached function
                 # or method
                 if filename.startswith(SAGE_SRC):
                     filename = filename[len(SAGE_SRC):]
                 elif filename.startswith(SAGE_LIB):
                     filename = filename[len(SAGE_LIB):]
                 file_info = "File: %s (starting at line
 %d)\n"%(filename,sourcelines[1])
                 doc = file_info+(f.func_doc or '')
 }}}
 As you can see, the code actively strips away the part that should really
 still be there. This change was made on #13432. Would it be very wrong to
 just do nothing with the filename here and simply report whatever gets
 reported on the original file?

 Proposed doctest:
 {{{
 sage: M=IntegerModRing(7)
 sage: from sage.misc.sageinspect import sage_getfile
 sage: os.path.exists(sage_getfile(M.is_finite))
 True
 sage: os.path.exists(sage_getfile(M.is_field)) #this presently fails
 True

 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15184>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to