Skip to content

Commit 5e7e1ba

Browse files
committed
avoid naming cython attributes __module__
1 parent 01075fc commit 5e7e1ba

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/sage/misc/cachefunc.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cpdef cache_key(o)
55

66
cdef class CachedFunction():
77
cdef public str __name__
8-
cdef public str __module__
8+
cdef public str __cached_module__
99
cdef ArgumentFixer _argument_fixer
1010
cdef public f
1111
cdef public cache # not always of type <dict>
@@ -20,7 +20,7 @@ cdef class CachedFunction():
2020
cdef class CachedMethod():
2121
cdef str _cache_name
2222
cdef public str __name__
23-
cdef public str __module__
23+
cdef public str __cached_module__
2424
cdef CachedFunction _cachedfunc
2525
cdef Py_ssize_t nargs
2626
cpdef _get_instance_cache(self, inst)

src/sage/misc/cachefunc.pyx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,17 @@ cdef class CachedFunction():
774774
else:
775775
self.__name__ = f.__name__
776776
try:
777-
self.__module__ = f.__module__
777+
self.__cached_module__ = f.__module__
778778
except AttributeError:
779-
self.__module__ = f.__objclass__.__module__
779+
self.__cached_module__ = f.__objclass__.__module__
780780
if argument_fixer is not None: # it is None unless the argument fixer
781781
# was known previously. See #15038.
782782
self._argument_fixer = argument_fixer
783783

784+
@property
785+
def __module__(self):
786+
return self.__cached_module__
787+
784788
cdef get_key_args_kwds(self, tuple args, dict kwds):
785789
"""
786790
Return the key in the cache to be used when ``args`` and
@@ -841,7 +845,7 @@ cdef class CachedFunction():
841845
sage: loads(dumps(hilbert_class_polynomial)) is hilbert_class_polynomial #indirect doctest # needs sage.schemes
842846
True
843847
"""
844-
return _cached_function_unpickle, (self.__module__, self.__name__, self.cache)
848+
return _cached_function_unpickle, (self.__cached_module__, self.__name__, self.cache)
845849

846850
#########
847851
## Introspection
@@ -2698,7 +2702,11 @@ cdef class CachedMethod():
26982702
self._cache_name = '_cache__' + (name or f.__name__)
26992703
self._cachedfunc = CachedFunction(f, classmethod=True, name=name, key=key, do_pickle=do_pickle)
27002704
self.__name__ = self._cachedfunc.__name__
2701-
self.__module__ = self._cachedfunc.__module__
2705+
self.__cached_module__ = self._cachedfunc.__module__
2706+
2707+
@property
2708+
def __module__(self):
2709+
return self.__cached_module__
27022710

27032711
def __call__(self, inst, *args, **kwds):
27042712
"""

0 commit comments

Comments
 (0)