Skip to content

Commit 37b2388

Browse files
committed
gh-118824: Remove deprecated master_open and slave_open from pty
1 parent 2f4db5a commit 37b2388

File tree

3 files changed

+4
-39
lines changed

3 files changed

+4
-39
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ Removed
109109
are removed. They had previously raised a :exc:`DeprecationWarning`
110110
since Python 3.12.
111111

112+
* Remove deprecated ``pty.master_open`` and ``pty.slave_open``.
113+
They had previously raised a :exc:`DeprecationWarning` since Python 3.12.
114+
112115
Porting to Python 3.14
113116
======================
114117

Lib/pty.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,6 @@ def openpty():
3535
slave_fd = slave_open(slave_name)
3636
return master_fd, slave_fd
3737

38-
def master_open():
39-
"""master_open() -> (master_fd, slave_name)
40-
Open a pty master and return the fd, and the filename of the slave end.
41-
Deprecated, use openpty() instead."""
42-
43-
import warnings
44-
warnings.warn("Use pty.openpty() instead.", DeprecationWarning, stacklevel=2) # Remove API in 3.14
45-
46-
try:
47-
master_fd, slave_fd = os.openpty()
48-
except (AttributeError, OSError):
49-
pass
50-
else:
51-
slave_name = os.ttyname(slave_fd)
52-
os.close(slave_fd)
53-
return master_fd, slave_name
54-
55-
return _open_terminal()
56-
5738
def _open_terminal():
5839
"""Open pty master and return (master_fd, tty_name)."""
5940
for x in 'pqrstuvwxyzPQRST':
@@ -66,26 +47,6 @@ def _open_terminal():
6647
return (fd, '/dev/tty' + x + y)
6748
raise OSError('out of pty devices')
6849

69-
def slave_open(tty_name):
70-
"""slave_open(tty_name) -> slave_fd
71-
Open the pty slave and acquire the controlling terminal, returning
72-
opened filedescriptor.
73-
Deprecated, use openpty() instead."""
74-
75-
import warnings
76-
warnings.warn("Use pty.openpty() instead.", DeprecationWarning, stacklevel=2) # Remove API in 3.14
77-
78-
result = os.open(tty_name, os.O_RDWR)
79-
try:
80-
from fcntl import ioctl, I_PUSH
81-
except ImportError:
82-
return result
83-
try:
84-
ioctl(result, I_PUSH, "ptem")
85-
ioctl(result, I_PUSH, "ldterm")
86-
except OSError:
87-
pass
88-
return result
8950

9051
def fork():
9152
"""fork() -> (pid, master_fd)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove deprecated ``pty.master_open`` and ``pty.slave_open``.

0 commit comments

Comments
 (0)