[issue39683] 2to3 fix_exitfunc suggests duplicated import of atexit module

2021-10-20 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed
superseder:  -> Close 2to3 issues and list them here

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39683] 2to3 fix_exitfunc suggests duplicated import of atexit module

2020-02-25 Thread Paulo Henrique Silva


Change by Paulo Henrique Silva :


--
keywords: +patch
nosy: +phsilva
nosy_count: 1.0 -> 2.0
pull_requests: +18015
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18654

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39683] 2to3 fix_exitfunc suggests duplicated import of atexit module

2020-02-18 Thread ilya


New submission from ilya :

Consider the following code:

import sys

def foo():
print(1)

def bar():
print(2)

if input("case: ") == 1:
sys.exitfunc = foo
else:
sys.exitfunc = bar

2to3 -f exitfunc suggests to fix it as follows:

--- a.py(original)
+++ a.py(refactored)
@@ -1,4 +1,6 @@
 import sys
+import atexit
+import atexit
 
 def foo():
 print(1)
@@ -7,6 +9,6 @@
 print(2)
 
 if input("case: ") == 1:
-sys.exitfunc = foo
+atexit.register(foo)
 else:
-sys.exitfunc = bar
+atexit.register(bar)

So it seems that it produces one import of atexit module per each use of 
sys.exitfunc.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 362245
nosy: ilya
priority: normal
severity: normal
status: open
title: 2to3 fix_exitfunc suggests duplicated import of atexit module
type: behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com