bpo-39683: 2to3 fix_exitfunc suggests duplicated import of atexit module by phsilva · Pull Request #18654 · python/cpython
from lib2to3 import pytree, fixer_base from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms, does_tree_import
class FixExitfunc(fixer_base.BaseFix):
# Do not add import if already present (multiple sys.atexit's) if does_tree_import(None, "atexit", self.sys_import.parent): return
# Now add an atexit import after the sys import. names = self.sys_import.children[1] if names.type == syms.dotted_as_names: