ยปCore Development>Code coverage>Lib/lib2to3/fixes/fix_methodattrs.py

Python code coverage for Lib/lib2to3/fixes/fix_methodattrs.py

#countcontent
1n/a"""Fix bound method attributes (method.im_? -> method.__?__).
2n/a"""
3n/a# Author: Christian Heimes
4n/a
5n/a# Local imports
6n/afrom .. import fixer_base
7n/afrom ..fixer_util import Name
8n/a
9n/aMAP = {
10n/a "im_func" : "__func__",
11n/a "im_self" : "__self__",
12n/a "im_class" : "__self__.__class__"
13n/a }
14n/a
15n/aclass FixMethodattrs(fixer_base.BaseFix):
16n/a BM_compatible = True
17n/a PATTERN = """
18n/a power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
19n/a """
20n/a
21n/a def transform(self, node, results):
22n/a attr = results["attr"][0]
23n/a new = MAP[attr.value]
24n/a attr.replace(Name(new, prefix=attr.prefix))