Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit042b492

Browse files
miss-islingtongpsheadpicnixz
authored
[3.12]gh-118761: Revert "Improve import time ofsubprocess (GH-129427)" (GH-130201) (#130205)
gh-118761: Revert "Improve import time of `subprocess` (GH-129427)" (GH-130201)* Revert "gh-118761: Improve import time of `subprocess` (GH-129427)"This reverts commit49f2465.Also known asf502c8f in 3.13 (PRGH-129447)Also known asf65aa0d in 3.12 (PRGH-129448)This caused bugs in the `__del__` finalizer:#118761 (comment)---------(cherry picked from commitae30646)Co-authored-by: Gregory P. Smith <greg@krypto.org>Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent4f09a85 commit042b492

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

‎Lib/subprocess.py‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
importbuiltins
4444
importerrno
4545
importio
46+
importlocale
4647
importos
4748
importtime
49+
importsignal
4850
importsys
4951
importthreading
5052
importwarnings
@@ -136,8 +138,6 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
136138

137139
def__str__(self):
138140
ifself.returncodeandself.returncode<0:
139-
# Lazy import to improve module import time
140-
importsignal
141141
try:
142142
return"Command '%s' died with %r."% (
143143
self.cmd,signal.Signals(-self.returncode))
@@ -375,8 +375,6 @@ def _text_encoding():
375375
ifsys.flags.utf8_mode:
376376
return"utf-8"
377377
else:
378-
# Lazy import to improve module import time
379-
importlocale
380378
returnlocale.getencoding()
381379

382380

@@ -1657,9 +1655,6 @@ def send_signal(self, sig):
16571655
# Don't signal a process that we know has already died.
16581656
ifself.returncodeisnotNone:
16591657
return
1660-
1661-
# Lazy import to improve module import time
1662-
importsignal
16631658
ifsig==signal.SIGTERM:
16641659
self.terminate()
16651660
elifsig==signal.CTRL_C_EVENT:
@@ -1764,9 +1759,6 @@ def _posix_spawn(self, args, executable, env, restore_signals,
17641759

17651760
kwargs= {}
17661761
ifrestore_signals:
1767-
# Lazy import to improve module import time
1768-
importsignal
1769-
17701762
# See _Py_RestoreSignals() in Python/pylifecycle.c
17711763
sigset= []
17721764
forsignamein ('SIGPIPE','SIGXFZ','SIGXFSZ'):
@@ -2216,13 +2208,9 @@ def send_signal(self, sig):
22162208
defterminate(self):
22172209
"""Terminate the process with SIGTERM
22182210
"""
2219-
# Lazy import to improve module import time
2220-
importsignal
22212211
self.send_signal(signal.SIGTERM)
22222212

22232213
defkill(self):
22242214
"""Kill the process with SIGKILL
22252215
"""
2226-
# Lazy import to improve module import time
2227-
importsignal
22282216
self.send_signal(signal.SIGKILL)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Reverts a change in the previous release attempting to make some stdlib
2+
imports used within the:mod:`subprocess` module lazy as this was causing
3+
errors during ``__del__`` finalizers calling methods such as ``terminate``, or
4+
``kill``, or ``send_signal``.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp