Uh oh!
There was an error while loading. Please reload this page.
gh-124405: Fix NameError in openpty - #124406
Conversation
There was a problem hiding this comment.
Thanks, this looks like the correct inlining of slave_open from #118826. Adding more test coverage sounds good though!
sobolevn
commented
Sep 24, 2024
Thanks for the review! I need help adding tests, since I cannot reproduce this on my machine :( |
hauntsaninja
commented
Sep 24, 2024
"highly problematic" indeed ;-) https://github.com/python/typeshed/pull/6807/files#diff-f28c4d3b27ed19db8e4154e55b1ad119f6655aad863bd3e92d9aee2d481589d7R72 |
vstinner
commented
Sep 24, 2024
I tried to test this change by removing importosimportptydelos.openptymaster_fd, slave_fd=pty.openpty()
os.close(master_fd)
os.close(slave_fd)But it fails on Linux with: Traceback (mostrecentcalllast):
File"/home/vstinner/python/main/x.py", line4, in<module>master_fd, slave_fd=pty.openpty()
~~~~~~~~~~~^^File"/home/vstinner/python/main/Lib/pty.py", line34, inopenptymaster_fd, slave_name=_open_terminal()
~~~~~~~~~~~~~~^^File"/home/vstinner/python/main/Lib/pty.py", line58, in_open_terminalraiseOSError('out of pty devices')
OSError: outofptydevicesOn my Fedora 41, I have no It seems like os.openpty() is implemented by communicating with |
vstinner
commented
Sep 24, 2024
Same on FreeBSD. On FreeBSD, os.openpty() is implemented with (syscalls recorded by truss): |
vstinner
commented
Sep 24, 2024
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 :-) |
sobolevn
commented
Sep 24, 2024
@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 :)
openptyafter #118826 #124405