PY-9342 Distinguish between function and method types

This commit is contained in:
Mikhail Golubev
2014-08-18 13:15:04 +04:00
parent a135c36544
commit a1ae56b0f9
12 changed files with 234 additions and 25 deletions
@@ -1009,6 +1009,8 @@ class ModuleRedeclarator(object):
self.classes_buf.out(0, txt)
txt = create_function()
self.classes_buf.out(0, txt)
txt = create_method()
self.classes_buf.out(0, txt)
# Fake <type 'namedtuple'>
if version[0] >= 3 or (version[0] == 2 and version[1] >= 6):
@@ -115,6 +115,25 @@ class __function(object):
"""
return txt
def create_method():
txt = """
class __method(object):
'''A mock class representing method type.'''
def __init__(self):
"""
if version[0] == 2:
txt += """
self.im_class = None
self.im_self = None
self.im_func = None
"""
if version[0] >= 3 or (version[0] == 2 and version[1] >= 6):
txt += """
self.__func__ = None
self.__self__ = None
"""
return txt
def _searchbases(cls, accum):
# logic copied from inspect.py