| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
I don't see any new tests. There should be at least one that fails before the new code is applied which then passes after it is applied.
The current tests are in Lib/test/test_pty.py.
Sorry, something went wrong.
|
Sir, thank you for taking the time to review this. I understand. While this was originally meant to be applied, now it is merely a sample. I have made several other improvements, and the final result is here: https://github.com/8vasu/pypty2 The final result has conflicts with this patch. While there is nothing wrong with this patch, it should not be applied. However, I still suggest that this tiny change be used as a starting point to get a sense of what can happen if window resizing is not present. I will add a test now. I will also reupload the png images to bpo. |
Sorry, something went wrong.
|
I have added the before and after screenshots and the short example that I had used to test this to the BPO issue. This example is from the docs ( see https://docs.python.org/3/library/pty.html ). I took the screenshots to make it easy for the reviewer: this is a visual change. Please follow these steps in indicated order to reproduce the issue:
The output is expected to be wrapped around the edges of the xterm window, making it hard to visually parse. Note that this patch does NOT handle SIGWINCH. It merely sets initial window size for slave. Therefore, if the xterm window is resized AFTER script.py is started, this patch will not resize slave accordingly. I have added that functionality to pypty2. More rigorous stty-based tests will be added to pypty2 if you find this smaller change useful. These changes are very useful if one uses a tiling window manager. |
Sorry, something went wrong.
|
May I please have a short chat session with you on freenode #python-dev sometime? |
Sorry, something went wrong.
|
Unfortunately I have never learned IRC. If I understand what you would like to do, which is to simply replace the current pty with your pypty2 package, I think the first step is going to be to add a bunch of tests to the current pty module. There should be a test for everything that the current pty does correctly. Once you have that, it will be more reasonable to substitute yours in because we can verify that everything that used to work, still does. You should also add tests for the known problems that the current pty has, and guard them with @expectedFailure. I know it's a big task, but doing it would prove a couple things:
Okay, apparently I am now registered on freenode. Feel free to look me up! |
Sorry, something went wrong.
There was a problem hiding this comment.
From my understanding, writing a test for this PR seems to mostly be a matter of creating a terminal from STDIN with a specified window size, and then reading the FD's (slave_fd) window size to ensure it's the same after it's spawned. Since pty.spawn() doesn't appear to expose the FD for the terminal window, you would write the tests against login_tty(). Alternatively, you could create a mock version of pty.spawn() that exposes the FD or allows you to pass a pair created from os.opentty() rather than within pty.spawn() (purely for testing purposes, within test_pty -- this could be potentially written as a nested function within something like test_spawn_winsize()).
TL;DR the test(s) should somehow address the change that pty.spawn() now sets window size based on STDIN.
(I'm very far from an expert with pty, but hopefully the above gives you a general idea of what the appropriate tests might involve. If/when Thomas (@Yhg1s) gets around to reviewing the PR, he could have more detailed feedback.)
Edit: For additional context, I left this review comment based on what the OP wrote in core-mentorship, they seemed to be seeking some guidance on how the unit test(s) should be written for this change.
Sorry, something went wrong.
|
@ethanfurman @aeros This was very helpful. I (we :D ?) can work on this during weekends. Note: This pull request adds login_tty() to pty because I wanted to avoid editing multiple files. It does not belong there. In pypty2, the pty module appropriately imports login() from tty; I added 3 new functions to the latter. |
Sorry, something went wrong.
|
Here you go: https://bugs.python.org/issue41818 I have started doing my homework on unittest. I am tempted to go the mock function route for all pty.spawn() tests. Is there any particular time during next weekend when you will be available on IRC #python-dev? Thank you for your patience. |
Sorry, something went wrong.
|
@ethanfurman Would the mock function route (as I suggested earlier) be reasonable in the unit test(s) for this specific change? Just wanted to double check before the author invests too much time into it, since I have not worked with the internals of tty previously. |
Sorry, something went wrong.
|
The purpose of mock is to be a stand-in for supporting parts of a test that aren't actually the target of the tests. For example, if you have a function that returns data from a database using a complex query then your test should be verifying that the created query is correct, so you would use mock to simulate the database connection. In this case the target of the test is the window itself, and its size -- so a test needs to be able to create the window, and then retrieve information about it, and mock won't help us with that. |
Sorry, something went wrong.
|
@ethanfurman I get it. Upon request of @aeros, I will use modified terminology for the pty ends. I will use mother/son. I have to move the son window size setting/SIGWINCH functionality to pty2.openpty() itself. It would also be a good idea to add that functionality to pty2.fork(). Then pty2.spawn() can simply call pty2.fork(). This should actually increase functionality and code reuse. Also, that way testing should become simpler: termios and winsize tests for son will be added to the existing pty.openpty() test. The only additional tests that need to be added to pty2.spawn() are the ones that deal with signal blocking and the hang issue on non-Linux platforms. Expect some of this progress to happen on next Saturday. If you have time to spare on next Saturday, then we can have a short chat on IRC :) Let me know the particular time. |
Sorry, something went wrong.
|
Cool. Instead of mother/son, though, use parent/child. If it looks like I'll time on Saturday I'll post a comment here. |
Sorry, something went wrong.
|
Haha. Got it! The reason why I used mother/son was that the initials still stay the same. If it has to be gender neutral, then we should try to come up with some other terminology that does not involve a human relationship at all. We should avoid using parent/child ( or server/client ) at all costs because that will cause massive amount of confusion in a project that already uses these terms in some other context. For example, pty uses parent/child to refer to processes. Using parent/child to refer to the pty fds will make search and replace much harder. Also, instead of just writing "master", we will complicate our lives by having to write "parent end of pty" each time. We cannot use source/sink because that does not suggest a correct relationship; both the ends can serve as data sources/sinks depending on situation. The original terminology of master/slave is very similar to controller/robot; in fact, "robot" is from Czech "robota", which means "forced labor". As a result, controller/robot is not an option. I was actually thinking about using remote/tdev or remote/pterm or remote/ptty or something along those lines. This is appropriate because the slave end is always supposed to be a tty device [ isatty(slave_fd) ] and the master end is something that can be used by the parent process to control said device. |
Sorry, something went wrong.
Why not call it something like parent_fd/child_term? The other could be changed to parent_proc and child_proc as well, if needed (assuming it's not backwards incompatible). I think the main issue is that "parent" and "child" are used to describe too many different things, but that can be addressed by making the variables more specific to the use case. That being said, I think either remote/pterm (as suggested above) or controller/pterm would also work. I'll leave it up to @ethanfurman since my experience with pty in general is likely far less. :-)
Not to go too deep into the terminology rabbit hole, but I think it's perfectly reasonable to base the connotation of a term in a project from the primary language it uses (English in this case) rather than pursuing every culture's. Otherwise, the number of useful analogy terms starts to become very limited to an extent that I would consider to be impractical for ease of communication. So, I'm not personally opposed to controller/robot, when it fits. |
Sorry, something went wrong.
|
Thank you for the feedback @aeros. As you said, not to go too deep into the terminology rabbit hole, but here is a final suggestion toward which I am inclined: tcntl/tdev. They are short and suggestive. tcntl = "terminal controller" is appropriate because
tdev = "terminal device" is appropriate because
If @ethanfurman @aeros like these terms, then I will start to use them in pypty2 :) |
Sorry, something went wrong.
|
Updates: now pty2.openpty() and pty2.fork() accept a termios and a winsize as optional arguments, just like openpty(3) and forkpty(3). As mentioned earlier, this will enable us to write window resizing tests against pty2.openpty() instead of having to deal with the more complicated pty2.spawn(). Also, a very convenient tty.getwinsz() has been added! The unittests have not been written yet; that is the goal of next Saturday. While I feel like writing the tests will not be very difficult, I can benefit immensely from your opinion. For example, what would be an acceptable way to write the *BSD hang test? If either of you can find time for a short chat during next weekend, please let me know. In any case, I will work on the project again on next Saturday. Edit: the terminology has not been changed yet. |
Sorry, something went wrong.
|
Updates: thank you for being patient. I have added the main tests to pypty2: slave termios, slave winsize, and FreeBSD hang. Do you prefer a pull request on GitHub or do you want me to upload pypty2 to bpo first? Edit: I can make a pull request/upload the files on next Saturday. |
Sorry, something went wrong.
|
Sir, I have created the first pull request [ #22962 ]. Thank you very much for making me do this :) I now have some experience with python's unittest library! To make it easier for you, this pull request only includes the tests from pypty2; I will make subsequent pull requests based on your suggestions. The new tests are
As you suggested, I have added @expectedfailure for no. 2 and no. 3 and a custom @expectedFailureOnBSD for no. 4. Edit: @expectedfailure has been changed to @expectedFailureIfStdinIsTTY since the automated tests on GitHub were failing otherwise: their stdin is not a tty. Please run the tests on a tty to achieve desired results :) |
Sorry, something went wrong.
|
I need this fix in a project that I'm working on. What is missing to merge the branch? |
Sorry, something went wrong.
|
This is being done in a series of PRs. I do not want to make a hasty fix
for this. To expedite the process can you please help review some of my
PRs? Please see bpo-41818. bpo-41541 is abandoned. Thank you.
…On Wed, Apr 27, 2022, 3:10 AM Paul Laffitte ***@***.***> wrote:
I need this fix in a project that I'm working on. What is missing to merge
the branch?
—
Reply to this email directly, view it on GitHub
<#21861 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQDGGD5JILUV6SJKUD25DPLVHDY7RANCNFSM4P6V42AQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sorry, something went wrong.
|
Ok, I understand. Thanks for the quick answer. I took a look at your PRs, but I don't really know what could I do to help. I never contributed to python before and it looks like some people are already reviewing them, so I feel I will not be very useful in this context 😅 |
Sorry, something went wrong.
|
Thank you for understanding :) I am trying my best to get this done. The
python core devs (I am not one of them) have limited time; they are also
doing their best to help us.
…On Thu, Apr 28, 2022, 12:28 PM Paul Laffitte ***@***.***> wrote:
Ok, I understand. Thanks for the quick answer. I took a look at your PRs,
but I don't really know what could I do to help. I never contributed to
python before and it looks like some people are already reviewing them, so
I feel I will not be very useful in this context 😅
—
Reply to this email directly, view it on GitHub
<#21861 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQDGGD6JCZS76DGP2WOECEDVHLDCHANCNFSM4P6V42AQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sorry, something went wrong.
- window size cf. python/cpython#21861 - ctrl+R
I will close the PR and issue. If the situation changed, please reopen (or comment, if you don't have permission). In case it is reopened: This will need docs and tests. Let's keep inclusive terminology for another PR -- it's important, but also complicated, orthogonal to the functionality, and best discussed with another group of people (see PEP-732). For now, be consistent with terminology that's already in the docs, and in the man pages of the POSIX API we're wrapping: master/slave. |
Sorry, something went wrong.
|
@encukou Thank you for closing this. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue41541