:func:`~multiprocessing.set_start_method` APIs to explicitly specify when
your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`.
+* :mod:`pty` has two undocumented ``master_open()`` and ``slave_open()``
+ functions that have been deprecated since Python 2 but only gained a
+ proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14.
+
Pending Removal in Future Versions
----------------------------------
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):
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
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)