Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
changed to new method attribute names (im_func -> __func__)
Browse files Browse the repository at this point in the history
5 .py modules were changed by the 2to3 tool
   (one was imcomplete as it had a hasattr() function)
2 .pyx were changed manually
1 additional .py module had im_func in a doc-test
  • Loading branch information
wluebbe committed Mar 26, 2014
1 parent 9db8c5c commit addb5a6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/sage/categories/sets_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def _test_elements_eq_transitive(self, **options):
We test a non transitive equality::
sage: R = Zp(3)
sage: Sets().ParentMethods._test_elements_eq_transitive.im_func(R,elements=[R(3,2),R(3,1),R(0)])
sage: Sets().ParentMethods._test_elements_eq_transitive.__func__(R,elements=[R(3,2),R(3,1),R(0)])
Traceback (most recent call last):
...
AssertionError: non transitive equality:
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/sf/k_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,9 @@ def __init__(self, kBoundedRing, prefix):
# The following are meant to be inherited with the category framework, but
# this fails because they are methods of Parent. The trick below overcomes
# this problem.
__getitem__ = KBoundedQuotientBases.ParentMethods.__getitem__.im_func
_repr_term = KBoundedQuotientBases.ParentMethods._repr_term.im_func
_element_constructor_ = KBoundedQuotientBases.ParentMethods._element_constructor_.im_func
__getitem__ = KBoundedQuotientBases.ParentMethods.__getitem__.__func__
_repr_term = KBoundedQuotientBases.ParentMethods._repr_term.__func__
_element_constructor_ = KBoundedQuotientBases.ParentMethods._element_constructor_.__func__
_element_constructor = _element_constructor_

class kMonomial(KBoundedQuotientBasis):
Expand Down
24 changes: 12 additions & 12 deletions src/sage/combinat/sf/new_kschur.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def counit(self, element):

class ElementMethods:

__mul__ = Magmas.ElementMethods.__mul__.im_func
__mul__ = Magmas.ElementMethods.__mul__.__func__

def _mul_(self, other):
r"""
Expand Down Expand Up @@ -1002,10 +1002,10 @@ def __init__(self, kBoundedRing):
# The following are meant to be inherited with the category framework, but
# this fails because they are methods of Parent. The trick below overcomes
# this problem.
__getitem__ = KBoundedSubspaceBases.ParentMethods.__getitem__.im_func
_repr_term = KBoundedSubspaceBases.ParentMethods._repr_term.im_func
_convert_map_from_ = KBoundedSubspaceBases.ParentMethods._convert_map_from_.im_func
_element_constructor_ = KBoundedSubspaceBases.ParentMethods._element_constructor_.im_func
__getitem__ = KBoundedSubspaceBases.ParentMethods.__getitem__.__func__
_repr_term = KBoundedSubspaceBases.ParentMethods._repr_term.__func__
_convert_map_from_ = KBoundedSubspaceBases.ParentMethods._convert_map_from_.__func__
_element_constructor_ = KBoundedSubspaceBases.ParentMethods._element_constructor_.__func__
_element_constructor = _element_constructor_

def _repr_(self):
Expand Down Expand Up @@ -1221,11 +1221,11 @@ def __init__(self, kBoundedRing):
# The following are meant to be inherited with the category framework, but
# this fails because they are methods of Parent. The trick below overcomes
# this problem.
__getitem__ = KBoundedSubspaceBases.ParentMethods.__getitem__.im_func
_repr_term = KBoundedSubspaceBases.ParentMethods._repr_term.im_func
__getitem__ = KBoundedSubspaceBases.ParentMethods.__getitem__.__func__
_repr_term = KBoundedSubspaceBases.ParentMethods._repr_term.__func__
_convert_map_from_ =\
KBoundedSubspaceBases.ParentMethods._convert_map_from_.im_func
_element_constructor_ = KBoundedSubspaceBases.ParentMethods._element_constructor_.im_func
KBoundedSubspaceBases.ParentMethods._convert_map_from_.__func__
_element_constructor_ = KBoundedSubspaceBases.ParentMethods._element_constructor_.__func__
_element_constructor = _element_constructor_

def _repr_(self):
Expand Down Expand Up @@ -1299,9 +1299,9 @@ def __init__(self, kBoundedRing):
# The following are meant to be inherited with the category framework, but
# this fails because they are methods of Parent. The trick below overcomes
# this problem.
__getitem__ = KBoundedSubspaceBases.ParentMethods.__getitem__.im_func
_repr_term = KBoundedSubspaceBases.ParentMethods._repr_term.im_func
_element_constructor_ = KBoundedSubspaceBases.ParentMethods._element_constructor_.im_func
__getitem__ = KBoundedSubspaceBases.ParentMethods.__getitem__.__func__
_repr_term = KBoundedSubspaceBases.ParentMethods._repr_term.__func__
_element_constructor_ = KBoundedSubspaceBases.ParentMethods._element_constructor_.__func__
_element_constructor = _element_constructor_

def _repr_(self):
Expand Down
22 changes: 11 additions & 11 deletions src/sage/misc/fpickle.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,31 @@ def call_pickled_function(fpargs):
# most functionality it provides
def pickleMethod(method):
'support function for copy_reg to pickle method refs'
return unpickleMethod, (method.im_func.__name__,
method.im_self,
return unpickleMethod, (method.__func__.__name__,
method.__self__,
method.im_class)

def unpickleMethod(im_name,
im_self,
__self__,
im_class):
'support function for copy_reg to unpickle method refs'
try:
unbound = getattr(im_class,im_name)
if im_self is None:
if __self__ is None:
return unbound
bound=types.MethodType(unbound.im_func,
im_self)
bound=types.MethodType(unbound.__func__,
__self__)
return bound
except AttributeError:
assert im_self is not None,"No recourse: no instance to guess from."
assert __self__ is not None,"No recourse: no instance to guess from."
# Attempt a common fix before bailing -- if classes have
# changed around since we pickled this method, we may still be
# able to get it by looking on the instance's current class.
unbound = getattr(im_self.__class__,im_name)
if im_self is None:
unbound = getattr(__self__.__class__,im_name)
if __self__ is None:
return unbound
bound=types.MethodType(unbound.im_func,
im_self)
bound=types.MethodType(unbound.__func__,
__self__)
return bound

copy_reg.pickle(types.MethodType,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/function_mangling.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ cdef class ArgumentFixer:
sage: class one:
... def __init__(self, x = 1):
... self.x = x
sage: af = ArgumentFixer(one.__init__.im_func, classmethod=True)
sage: af = ArgumentFixer(one.__init__.__func__, classmethod=True)
sage: af.fix_to_pos(1,2,3,a=31,b=2,n=3)
((1, 2, 3), (('a', 31), ('b', 2), ('n', 3)))
Expand Down
4 changes: 2 additions & 2 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def foo(x, a='\')"', b={not (2+1==3):'bar'}): return
if inspect.isfunction(obj):
func_obj = obj
elif inspect.ismethod(obj):
func_obj = obj.im_func
func_obj = obj.__func__
elif isclassinstance(obj):
if hasattr(obj,'_sage_src_'): #it may be a decorator!
source = sage_getsource(obj)
Expand Down Expand Up @@ -1638,7 +1638,7 @@ class ParentMethods:
raise IOError('could not find class definition')

if inspect.ismethod(object):
object = object.im_func
object = object.__func__
if inspect.isfunction(object):
object = object.func_code
if inspect.istraceback(object):
Expand Down
8 changes: 4 additions & 4 deletions src/sage/sets/set_from_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,13 @@ def __init__(self, f=None, **options):
else:
if hasattr(f, '__module__'):
self.__module__ = f.__module__
elif hasattr(f, 'im_func'):
self.__module__ = f.im_func.__module__
elif hasattr(f, '__func__'):
self.__module__ = f.__func__.__module__

if hasattr(f, '__name__'):
self.__name__ = f.__name__
elif hasattr(f, 'im_func'):
self.__name__ = f.im_func.__name__
elif hasattr(f, '__func__'):
self.__name__ = f.__func__.__name__

self.options = options

Expand Down

0 comments on commit addb5a6

Please sign in to comment.