aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/pty.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committershadchin <shadchin@yandex-team.com>2024-02-12 08:07:36 +0300
commitce1b7ca3171f9158180640c6a02a74b4afffedea (patch)
treee47c1e8391b1b0128262c1e9b1e6ed4c8fff2348 /contrib/tools/python3/src/Lib/pty.py
parent57350d96f030db90f220ce50ee591d5c5d403df7 (diff)
downloadydb-ce1b7ca3171f9158180640c6a02a74b4afffedea.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/pty.py')
-rw-r--r--contrib/tools/python3/src/Lib/pty.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/contrib/tools/python3/src/Lib/pty.py b/contrib/tools/python3/src/Lib/pty.py
index fefb63abfb..1d97994abe 100644
--- a/contrib/tools/python3/src/Lib/pty.py
+++ b/contrib/tools/python3/src/Lib/pty.py
@@ -40,6 +40,9 @@ def master_open():
Open a pty master and return the fd, and the filename of the slave end.
Deprecated, use openpty() instead."""
+ import warnings
+ warnings.warn("Use pty.openpty() instead.", DeprecationWarning, stacklevel=2) # Remove API in 3.14
+
try:
master_fd, slave_fd = os.openpty()
except (AttributeError, OSError):
@@ -69,6 +72,9 @@ def slave_open(tty_name):
opened filedescriptor.
Deprecated, use openpty() instead."""
+ import warnings
+ warnings.warn("Use pty.openpty() instead.", DeprecationWarning, stacklevel=2) # Remove API in 3.14
+
result = os.open(tty_name, os.O_RDWR)
try:
from fcntl import ioctl, I_PUSH
@@ -101,20 +107,8 @@ def fork():
master_fd, slave_fd = openpty()
pid = os.fork()
if pid == CHILD:
- # Establish a new session.
- os.setsid()
os.close(master_fd)
-
- # Slave becomes stdin/stdout/stderr of child.
- os.dup2(slave_fd, STDIN_FILENO)
- os.dup2(slave_fd, STDOUT_FILENO)
- os.dup2(slave_fd, STDERR_FILENO)
- if slave_fd > STDERR_FILENO:
- os.close(slave_fd)
-
- # Explicitly open the tty to make it become a controlling tty.
- tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR)
- os.close(tmp_fd)
+ os.login_tty(slave_fd)
else:
os.close(slave_fd)
@@ -192,7 +186,7 @@ def _copy(master_fd, master_read=_read, stdin_read=_read):
def spawn(argv, master_read=_read, stdin_read=_read):
"""Create a spawned process."""
- if type(argv) == type(''):
+ if isinstance(argv, str):
argv = (argv,)
sys.audit('pty.spawn', argv)