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-41818: Make test_openpty() avoid unexpected success due to number of rows and/or number of columns being == 0. #23526

Merged
merged 2 commits into from
Nov 27, 2020

Conversation

8vasu
Copy link
Contributor

@8vasu 8vasu commented Nov 26, 2020

Proposed proper fix for buildbot failures introduced after #22962 merging.

To check if pty.openpty() properly sets pty slave size based on the size of current stdin, PtyTest.test_openpty() was modifying the size of current stdin first. Let 'x' be the number of rows of stdin; then, we set the number of rows of stdin to some f(x) such that the function f does not have any fixed points; that is, f(x) != x for all x. In #22962, f(x) := x//5; unfortunately, in that case, f does have 0 as a fixed point [ 0//5 = 0 ]. Upon running

./python -c "import pty;pty.spawn('./python -m test -v test_pty'.split())"

unexpected success was reported on Debian; this indeed was due to the # of (rows, cols) being (0,0). The Gentoo buildbot was probably also running with stdin being a tty of size (0,0). The new choice of f(x) := x+1 solves the problem, since this f has no fixed points [ x+1=x has no solution. ]

TL;DR: instead of letting rows and cols of stdin be the floor of 1/5 of their original values, we now only increment their respective values by 1. Note, however, that the former is a more noticeable change when # of rows, cols are fairly large.

Signed-off-by: Soumendra Ganguly [email protected]

https://bugs.python.org/issue41818

@8vasu
Copy link
Contributor Author

8vasu commented Nov 26, 2020

@zware thank you for suggesting that helpful command. @asvetlov @ethanfurman here is my proposed proper fix.

@asvetlov
Copy link
Contributor

Let me check on the buildbot fleet. Just in case.

@asvetlov asvetlov added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 27, 2020
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @asvetlov for commit 1178d94873b7a72bcc1426cd4db7d525d7db1cec 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 27, 2020
Copy link
Contributor

@asvetlov asvetlov 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, a tiny polishing is needed

# Should not apply @unittest.expectedFailure() on Gentoo
# to keep the buildbot fleet happy.
return fun
# PLATFORM = platform.system()
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop this comment please, it is not required anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

target_stdin_winsz = struct.pack("HHHH", self.stdin_rows//5,
self.stdin_cols//5, 0, 0)
debug(f"original size: (rows={self.stdin_rows}, cols={self.stdin_cols})")
target_stdin_rows = self.stdin_rows + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a few words to describe the resize trick and why it is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added some comments. Please let me know if this looks good.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

…d/or number of columns being == 0.

Signed-off-by: Soumendra Ganguly <[email protected]>
@8vasu
Copy link
Contributor Author

8vasu commented Nov 27, 2020

I have made the requested changes; please review again. Also, I have rebased so that there is only one clean commit.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@asvetlov: please review the changes made to this pull request.

@asvetlov
Copy link
Contributor

Cool, thanks!

@8vasu
Copy link
Contributor Author

8vasu commented Nov 27, 2020

You're welcome!

@8vasu
Copy link
Contributor Author

8vasu commented Nov 27, 2020

The next pull request will make some additions to the tty module as preparation for making changes to pty.

@asvetlov
Copy link
Contributor

@8vasu please also take a look at test_master_read() failure on Solaris reported by https://bugs.python.org/issue41818#msg381930

We need to suppress the error for the problematic platform at least if there is no idea why SunOS behaves differently.

@8vasu
Copy link
Contributor Author

8vasu commented Nov 27, 2020

@asvetlov I am working on it now :) I have posted a comment in the bpo issue about the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants