bpo-39683: 2to3 fix_exitfunc suggests duplicated import of atexit module by phsilva · Pull Request #18654 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/lib2to3/fixes/fix_exitfunc.py
18 changes: 18 additions & 0 deletions Lib/lib2to3/tests/test_fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4527,6 +4527,24 @@ def test_simple(self):
"""
self.check(b, a)

def test_multiple(self):
b = """
import sys
if 42:
sys.exitfunc = my_atexit
else:
sys.exitfunc = my_otheratexit
"""
a = """
import sys
import atexit
if 42:
atexit.register(my_atexit)
else:
atexit.register(my_otheratexit)
"""
self.check(b, a)

def test_names_import(self):
b = """
import sys, crumbs
Expand Down