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

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

#countcontent
1n/a"""Fix function attribute names (f.func_x -> f.__x__)."""
2n/a# Author: Collin Winter
3n/a
4n/a# Local imports
5n/afrom .. import fixer_base
6n/afrom ..fixer_util import Name
7n/a
8n/a
9n/aclass FixFuncattrs(fixer_base.BaseFix):
10n/a BM_compatible = True
11n/a
12n/a PATTERN = """
13n/a power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals'
14n/a | 'func_name' | 'func_defaults' | 'func_code'
15n/a | 'func_dict') > any* >
16n/a """
17n/a
18n/a def transform(self, node, results):
19n/a attr = results["attr"][0]
20n/a attr.replace(Name(("__%s__" % attr.value[5:]),
21n/a prefix=attr.prefix))