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

Commit831695b

Browse files
miss-islingtongpsheadpicnixz
authored
[3.13]gh-118761: Revert "Improve import time ofsubprocess (GH-129427)" (GH-130201) (#130204)
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 parent2fcad2a commit831695b

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
@@ -142,8 +144,6 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
142144

143145
def__str__(self):
144146
ifself.returncodeandself.returncode<0:
145-
# Lazy import to improve module import time
146-
importsignal
147147
try:
148148
return"Command '%s' died with %r."% (
149149
self.cmd,signal.Signals(-self.returncode))
@@ -381,8 +381,6 @@ def _text_encoding():
381381
ifsys.flags.utf8_mode:
382382
return"utf-8"
383383
else:
384-
# Lazy import to improve module import time
385-
importlocale
386384
returnlocale.getencoding()
387385

388386

@@ -1667,9 +1665,6 @@ def send_signal(self, sig):
16671665
# Don't signal a process that we know has already died.
16681666
ifself.returncodeisnotNone:
16691667
return
1670-
1671-
# Lazy import to improve module import time
1672-
importsignal
16731668
ifsig==signal.SIGTERM:
16741669
self.terminate()
16751670
elifsig==signal.CTRL_C_EVENT:
@@ -1771,9 +1766,6 @@ def _posix_spawn(self, args, executable, env, restore_signals, close_fds,
17711766
"""Execute program using os.posix_spawn()."""
17721767
kwargs= {}
17731768
ifrestore_signals:
1774-
# Lazy import to improve module import time
1775-
importsignal
1776-
17771769
# See _Py_RestoreSignals() in Python/pylifecycle.c
17781770
sigset= []
17791771
forsignamein ('SIGPIPE','SIGXFZ','SIGXFSZ'):
@@ -2223,13 +2215,9 @@ def send_signal(self, sig):
22232215
defterminate(self):
22242216
"""Terminate the process with SIGTERM
22252217
"""
2226-
# Lazy import to improve module import time
2227-
importsignal
22282218
self.send_signal(signal.SIGTERM)
22292219

22302220
defkill(self):
22312221
"""Kill the process with SIGKILL
22322222
"""
2233-
# Lazy import to improve module import time
2234-
importsignal
22352223
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