Python 3: replace "im_self" by "__self__"

The Python 3 removed the "im_self" attribute. This patch
replaces "im_self" by "__self__" attribute.
Partial-Bug: #1282514

Change-Id: I53567c856b81c9b2fceaf131ee918dd850ac4f03
This commit is contained in:
Fengqian Gao 2014-02-26 20:34:19 +08:00
parent 19cf2e0d50
commit c07b38f806
1 changed files with 3 additions and 3 deletions

View File

@ -34,10 +34,10 @@ def getcallargs(function, *args, **kwargs):
# argnames but not in args or kwargs. Uses 'in' rather than '==' because
# some tests use 'self2'.
if 'self' in argnames[0] or 'cls' == argnames[0]:
# The function may not actually be a method or have im_self.
# The function may not actually be a method or have __self__.
# Typically seen when it's stubbed with mox.
if inspect.ismethod(function) and hasattr(function, 'im_self'):
keyed_args[argnames[0]] = function.im_self
if inspect.ismethod(function) and hasattr(function, '__self__'):
keyed_args[argnames[0]] = function.__self__
else:
keyed_args[argnames[0]] = None