gh-123228: fix return type for _ReadlineWrapper.get_line_buffer()#123281
gh-123228: fix return type for _ReadlineWrapper.get_line_buffer()#123281cfbolz merged 7 commits intopython:mainfrom
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.
this line is failing on windows. why is the except curses.error: pass needed anyway?
There was a problem hiding this comment.
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 <cfbolz@gmx.de>
|
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 <skirpichev@gmail.com> Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
|
GH-123293 is a backport of this pull request to the 3.13 branch. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
str, not abytesobject #123228