FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.12] gh-118761: Revert "Improve import time of `subprocess` (GH-129427)" (GH-130201) by miss-islington · Pull Request #130205 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 2 additions & 14 deletions Lib/subprocess.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
import builtins
import errno
import io
import locale
import os
import time
import signal
import sys
import threading
import warnings
Expand Down Expand Up @@ -136,8 +138,6 @@ def __init__(self, returncode, cmd, output=None, stderr=None):

def __str__(self):
if self.returncode and self.returncode < 0:
# Lazy import to improve module import time
import signal
try:
return "Command '%s' died with %r." % (
self.cmd, signal.Signals(-self.returncode))
Expand Down Expand Up @@ -375,8 +375,6 @@ def _text_encoding():
if sys.flags.utf8_mode:
return "utf-8"
else:
# Lazy import to improve module import time
import locale
return locale.getencoding()


Expand Down Expand Up @@ -1657,9 +1655,6 @@ def send_signal(self, sig):
# Don't signal a process that we know has already died.
if self.returncode is not None:
return

# Lazy import to improve module import time
import signal
if sig == signal.SIGTERM:
self.terminate()
elif sig == signal.CTRL_C_EVENT:
Expand Down Expand Up @@ -1764,9 +1759,6 @@ def _posix_spawn(self, args, executable, env, restore_signals,

kwargs = {}
if restore_signals:
# Lazy import to improve module import time
import signal

# See _Py_RestoreSignals() in Python/pylifecycle.c
sigset = []
for signame in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'):
Expand Down Expand Up @@ -2216,13 +2208,9 @@ def send_signal(self, sig):
def terminate(self):
"""Terminate the process with SIGTERM
"""
# Lazy import to improve module import time
import signal
self.send_signal(signal.SIGTERM)

def kill(self):
"""Kill the process with SIGKILL
"""
# Lazy import to improve module import time
import signal
self.send_signal(signal.SIGKILL)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Reverts a change in the previous release attempting to make some stdlib
imports used within the :mod:`subprocess` module lazy as this was causing
errors during ``__del__`` finalizers calling methods such as ``terminate``, or
``kill``, or ``send_signal``.

Back | FazBrowse Home | New Git URL