mirror of
https://github.com/python/cpython.git
synced 2025-11-27 13:45:25 +00:00
bpo-32596: Make lazy-load portable (GH-5316)
Global variables should not used as import target. Use temporary variable instead.
This commit is contained in:
parent
2fc98ae115
commit
4666ec597c
1 changed files with 6 additions and 4 deletions
|
|
@ -40,11 +40,13 @@ def __getattr__(name):
|
||||||
global ProcessPoolExecutor, ThreadPoolExecutor
|
global ProcessPoolExecutor, ThreadPoolExecutor
|
||||||
|
|
||||||
if name == 'ProcessPoolExecutor':
|
if name == 'ProcessPoolExecutor':
|
||||||
from .process import ProcessPoolExecutor
|
from .process import ProcessPoolExecutor as pe
|
||||||
return ProcessPoolExecutor
|
ProcessPoolExecutor = pe
|
||||||
|
return pe
|
||||||
|
|
||||||
if name == 'ThreadPoolExecutor':
|
if name == 'ThreadPoolExecutor':
|
||||||
from .thread import ThreadPoolExecutor
|
from .thread import ThreadPoolExecutor as te
|
||||||
return ThreadPoolExecutor
|
ThreadPoolExecutor = te
|
||||||
|
return te
|
||||||
|
|
||||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue