-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-123228: fix return type for _ReadlineWrapper.get_line_buffer() #123281
Conversation
implementation is fine, but why did you revert the test? |
This wasn't tested before and I'm not sure if this does make sense. |
Let's keep the test. If it had been tested before, we would have found the problem in PyPy long ago (which just shows a test is a good idea). |
This reverts commit 119362b.
Lib/test/test_pyrepl/test_pyrepl.py
Outdated
@@ -1,3 +1,4 @@ | |||
import curses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is failing on windows. why is the except curses.error: pass
needed anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Else this fails
Traceback (most recent call last):
File "/home/runner/work/cpython/cpython/Lib/test/test_pyrepl/test_pyrepl.py", line 522, in test_basic
self.assertIs(type(get_line_buffer()), str)
~~~~~~~~~~~~~~~^^
File "/home/runner/work/cpython/cpython/Lib/_pyrepl/readline.py", line 483, in get_line_buffer
return self.get_reader().get_unicode()
~~~~~~~~~~~~~~~^^
File "/home/runner/work/cpython/cpython/Lib/_pyrepl/readline.py", line 358, in get_reader
console = Console(self.f_in, self.f_out, encoding=ENCODING)
File "/home/runner/work/cpython/cpython/Lib/_pyrepl/unix_console.py", line 154, in __init__
curses.setupterm(term or None, self.output_fd)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_curses.error: setupterm: could not find terminfo database`
(e.g. here: https://github.com/python/cpython/actions/runs/10536985217/job/29197815100)
dropping the import doesn't work, that will still make the test fail if class TestPyReplOutput(TestCase):
...
def test_get_line_buffer_returns_str(self):
reader = self.prepare_reader(code_to_events("\n"))
wrapper = _ReadlineWrapper(reader=reader)
self.assertIs(type(wrapper.get_line_buffer()), str) which doesn't require curses at all. |
Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, I think!
Thanks @skirpichev for the PR, and @cfbolz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…() (pythonGH-123281) (cherry picked from commit ca18ff2) Co-authored-by: Sergey B Kirpichev <[email protected]> Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
GH-123293 is a backport of this pull request to the 3.13 branch. |
…r() (GH-123281) (#123293) gh-123228: fix return type for _ReadlineWrapper.get_line_buffer() (GH-123281) (cherry picked from commit ca18ff2) Co-authored-by: Sergey B Kirpichev <[email protected]> Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
str
, not abytes
object #123228