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

Correctness fix (pull #578) plus efficiency improvements #579

Merged
merged 26 commits into from
Jan 14, 2020

Conversation

dluyer
Copy link
Contributor

@dluyer dluyer commented Aug 2, 2019

Pull request combines the correctness fix in #578 and efficiency improvements to stop copying large amounts of data in numerous codepaths (and generally reduce data copies).

- Fix 'before' return on eof/timeout/error.
- Fix behavior when searchwindowsize is increased between calls to expect_loop (existing code could discard required content).

Note, this is less efficient, but it is correct.  The prior changes improved benchmarks but broke correctness; I haven't benchmarked to see if this is better or worse than the original code, before buffer_type use was introduced.  It would be possible to make this more efficient with further complexity.

Breakage introduced:
  pexpect@fd7332f#diff-244f4b51bfbbbcb072d1428a79b9f4f7

Prior partial fix:
  pexpect@5a2e63f#diff-244f4b51bfbbbcb072d1428a79b9f4f7
@dluyer
Copy link
Contributor Author

dluyer commented Aug 2, 2019

Note, obsoletes (includes) #578

@dluyer
Copy link
Contributor Author

dluyer commented Aug 2, 2019

Primary reasons for this change: The prior changes lost the meaning of seachwindowsize and introduced numerous copies of the entire buffer into some usage patterns. This change substantially reduces copies.

@Red-M
Copy link
Member

Red-M commented Sep 22, 2019

This looks fine but I'd prefer if the coverage didn't drop as much for this fix.
@takluyver Could you take a look when you get a chance?

@dluyer
Copy link
Contributor Author

dluyer commented Dec 10, 2019

What is it going to take to get this merged?

If I wrote a test which fails with the old code and succeeds with the new, would that be sufficient?

This has been pending a long time, and I'd really like to get it submitted.

Copy link
Member

@takluyver takluyver left a comment

Choose a reason for hiding this comment

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

Sorry this has lingered so long. Yes, I think it would be a good idea to add a test - besides anything else, it will ensure that we don't reintroduce the bug you're fixing! It might also help me to understand what it is you're fixing - I think I can see it, but it would be nice to make it explicit.

pexpect/expect.py Outdated Show resolved Hide resolved
@dluyer dluyer closed this Jan 9, 2020
@dluyer dluyer reopened this Jan 9, 2020
@dluyer
Copy link
Contributor Author

dluyer commented Jan 11, 2020

Requested refactoring done, three regression tests added. Please re-review, thanks!

pexpect/run.py Outdated Show resolved Hide resolved
pexpect/expect.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants