Jason R. Coombs  committed 23f2b00

save_method_args now runs natively on Python 3

  • Participants
  • Parent commits 4f719b0

Comments (0)

Files changed (2)

File irc/

 from __future__ import absolute_import
+import sys
+import operator
+__all__ = ['str', 'socketserver', 'method_name']
+py3 = sys.version_info >= (3,0)
 	str = unicode
 except NameError:
 	import socketserver
 except ImportError:
 	import SocketServer as socketserver
+method_name = operator.attrgetter('__name__' if py3 else 'func_name')

File irc/

 import functools
 import collections
+from . import _py2_compat
 def save_method_args(method):
     Wrap a method such that when it is called, we save the args and
     args_and_kwargs = collections.namedtuple('args_and_kwargs', 'args kwargs')
     def wrapper(self, *args, **kwargs):
-        attr_name = '_saved_' + method.func_name
+        attr_name = '_saved_' + _py2_compat.method_name(method)
         attr = args_and_kwargs(args, kwargs)
         setattr(self, attr_name, attr)
         return method(self, *args, **kwargs)