Skip to content
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

bpo-45223: Lib/pty.py: handle stdin I/O errors same way as master I/O errors #28388

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kanavin
Copy link
Contributor

@kanavin kanavin commented Sep 16, 2021

reading stdin can throw the same I/O errors as reading from master fd does,
e.g. when running under Yocto's test harness:

ERROR: test_spawn_doesnt_hang (test.test_pty.PtyTest)

Traceback (most recent call last):
File "/usr/lib/python3.10/test/test_pty.py", line 316, in test_spawn_doesnt_hang
pty.spawn([sys.executable, '-c', 'print("hi there")'])
File "/usr/lib/python3.10/pty.py", line 181, in spawn
_copy(master_fd, master_read, stdin_read)
File "/usr/lib/python3.10/pty.py", line 157, in _copy
data = stdin_read(STDIN_FILENO)
File "/usr/lib/python3.10/pty.py", line 132, in _read
return os.read(fd, 1024)
OSError: [Errno 5] Input/output error

So let's treat both channels the same.

Signed-off-by: Alexander Kanavin alex@linutronix.de

https://bugs.python.org/issue45223

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@kanavin

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Oct 17, 2021
@kanavin
Copy link
Contributor Author

kanavin commented Nov 5, 2021

Just signed the CLA, will check in a few days if it's active.

@CoolCat467
Copy link

@kanavin Just checked now and it still says no

@kanavin
Copy link
Contributor Author

kanavin commented Nov 11, 2021

@kanavin Just checked now and it still says no

If i type @kanavin into https://check-python-cla.herokuapp.com/ I get 500 Internal server error. How did you check?

@CoolCat467
Copy link

Need to use kanavin, without @ symbol

@kanavin
Copy link
Contributor Author

kanavin commented Nov 22, 2021

Need to use kanavin, without @ symbol

Right, I had it set on bpo with @. I removed that, and it looks good now.

Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good:
Ran 7 tests in 0.049s

OK (expected failures=1)

== Tests result: SUCCESS ==

@netlify
Copy link

netlify bot commented Dec 6, 2022

Deploy Preview for python-cpython-preview canceled.

Name Link
🔨 Latest commit 3c3c3bb
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/63905060686239000ad92955

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Dec 6, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

reading stdin can throw the same I/O errors as reading from master fd does,
e.g. when running under Yocto's test harness:
======================================================================
ERROR: test_spawn_doesnt_hang (test.test_pty.PtyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/test/test_pty.py", line 316, in test_spawn_doesnt_hang
    pty.spawn([sys.executable, '-c', 'print("hi there")'])
  File "/usr/lib/python3.10/pty.py", line 181, in spawn
    _copy(master_fd, master_read, stdin_read)
  File "/usr/lib/python3.10/pty.py", line 157, in _copy
    data = stdin_read(STDIN_FILENO)
  File "/usr/lib/python3.10/pty.py", line 132, in _read
    return os.read(fd, 1024)
OSError: [Errno 5] Input/output error

So let's treat both channels the same.

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
@furkanonder
Copy link
Contributor

@kanavin Can you explain the way to reproduce the error? I would like to try this in my local and check if the error still exists.

@kanavin
Copy link
Contributor Author

kanavin commented May 9, 2023

@kanavin Can you explain the way to reproduce the error? I would like to try this in my local and check if the error still exists.

We use this to run the tests:
https://git.yoctoproject.org/ptest-runner2/tree/

I just confirmed: when running python3 -m test.test_pty -v directly on the terminal it passes. When the same command is executed by ptest-runner with i/o handled by it, it fails as shown above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants