-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-124405: Fix NameError
in openpty
#124406
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks like the correct inlining of slave_open
from #118826. Adding more test coverage sounds good though!
Thanks for the review! I need help adding tests, since I cannot reproduce this on my machine :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to sleep now, will look tomorrow. Based on typeshed I_PUSH should exist on Linux?
"highly problematic" indeed ;-) https://github.com/python/typeshed/pull/6807/files#diff-f28c4d3b27ed19db8e4154e55b1ad119f6655aad863bd3e92d9aee2d481589d7R72 |
I tried to test this change by removing import os
import pty
del os.openpty
master_fd, slave_fd = pty.openpty()
os.close(master_fd)
os.close(slave_fd) But it fails on Linux with: Traceback (most recent call last):
File "/home/vstinner/python/main/x.py", line 4, in <module>
master_fd, slave_fd = pty.openpty()
~~~~~~~~~~~^^
File "/home/vstinner/python/main/Lib/pty.py", line 34, in openpty
master_fd, slave_name = _open_terminal()
~~~~~~~~~~~~~~^^
File "/home/vstinner/python/main/Lib/pty.py", line 58, in _open_terminal
raise OSError('out of pty devices')
OSError: out of pty devices On my Fedora 41, I have no It seems like os.openpty() is implemented by communicating with
|
Same on FreeBSD. On FreeBSD, os.openpty() is implemented with (syscalls recorded by truss):
|
I guess that os.openpty() is now commonly available, and nobody uses the _open_terminal() fallback code path anymore, which looks broken on most platforms. We should maybe do something with this code. Deprecate it. Remove it. I don't know :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@vstinner thanks a lot for your help! 👍 |
@ambv how can I test this change? This looks very platform specific, but it seems that you have a reproducer :)
openpty
after #118826 #124405