Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-118824: Remove deprecated master_open and slave_open from pty
  • Loading branch information
sobolevn committed May 9, 2024
commit 37b23888715f2a48e63465677fc0fa3f495bb101
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ Removed
are removed. They had previously raised a :exc:`DeprecationWarning`
since Python 3.12.

* Remove deprecated ``pty.master_open`` and ``pty.slave_open``.
They had previously raised a :exc:`DeprecationWarning` since Python 3.12.

Porting to Python 3.14
======================

Expand Down
39 changes: 0 additions & 39 deletions Lib/pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,6 @@ def openpty():
slave_fd = slave_open(slave_name)
return master_fd, slave_fd

def master_open():
"""master_open() -> (master_fd, slave_name)
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):
pass
else:
slave_name = os.ttyname(slave_fd)
os.close(slave_fd)
return master_fd, slave_name

return _open_terminal()

def _open_terminal():
"""Open pty master and return (master_fd, tty_name)."""
for x in 'pqrstuvwxyzPQRST':
Expand All @@ -66,26 +47,6 @@ def _open_terminal():
return (fd, '/dev/tty' + x + y)
raise OSError('out of pty devices')

def slave_open(tty_name):
Comment thread
sobolevn marked this conversation as resolved.
"""slave_open(tty_name) -> slave_fd
Open the pty slave and acquire the controlling terminal, returning
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
except ImportError:
return result
try:
ioctl(result, I_PUSH, "ptem")
ioctl(result, I_PUSH, "ldterm")
except OSError:
pass
return result

def fork():
"""fork() -> (pid, master_fd)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove deprecated ``pty.master_open`` and ``pty.slave_open``.
Comment thread
sobolevn marked this conversation as resolved.
Outdated