#17814: Make calling a cached method independent of source code inspection
--------------------------------+------------------------
Reporter: SimonKing | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-6.6
Component: distribution | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
--------------------------------+------------------------
Comment (by SimonKing):
Try this:
{{{
#!diff
diff --git a/src/sage/misc/cachefunc.pyx b/src/sage/misc/cachefunc.pyx
index a4276b9..515c74a 100644
--- a/src/sage/misc/cachefunc.pyx
+++ b/src/sage/misc/cachefunc.pyx
@@ -481,6 +481,12 @@ import sage.misc.weak_dict
from sage.misc.weak_dict import WeakValueDictionary
from sage.misc.decorators import decorator_keywords
+from cpython cimport PyObject
+
+cdef extern from "methodobject.h":
+ cdef int PyCFunction_GetFlags(PyObject *op)
+
+
cdef frozenset special_method_names = frozenset(['__abs__', '__add__',
'__and__', '__call__', '__cmp__', '__coerce__',
'__complex__', '__contains__', '__del__',
'__delattr__', '__delete__', '__delitem__', '__delslice__',
'__dir__', '__div__',
@@ -2672,6 +2678,7 @@ cdef class CachedMethod(object):
# we need to analyse the argspec
f = (<CachedFunction>self._cachedfunc).f
if self.nargs==0:
+ bla = PyCFunction_GetFlags(<PyObject *>f)
args, varargs, keywords, defaults = sage_getargspec(f)
if varargs is None and keywords is None and len(args)<=1:
self.nargs = 1
}}}
According to the crash report that I get, the error occurs in the line
`args, varargs, keywords, defaults = sage_getargspec(f)`, thus, ''after''
`PyCFunction_GetFlags` has returned something.
--
Ticket URL: <http://trac.sagemath.org/ticket/17814#comment:21>
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/d/optout.