8000 Remove no-\r assertion in print_formatted_text · cool-RR/python-prompt-toolkit@4336996 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4336996

Browse files
Nic Watsonjonathanslenders
authored andcommitted
Remove no-\r assertion in print_formatted_text
1 parent 0b22217 commit 4336996

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

prompt_toolkit/renderer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,11 @@ def print_formatted_text(
684684
else:
685685
output.reset_attributes()
686686

687+
# Eliminate carriage returns
688+
text = text.replace('\r', '')
689+
687690
# Assume that the output is raw, and insert a carriage return before
688691
# every newline. (Also important when the front-end is a telnet client.)
689-
assert '\r' not in text
690692
output.write(text.replace('\n', '\r\n'))
691693

692694
# Reset again.

tests/test_print_formatted_text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def test_print_formatted_text():
4949
assert b'hello' in f.data
5050
assert b'world' in f.data
5151

52+
@pytest.mark.skipif(
53+
is_windows(), reason="Doesn't run on Windows yet.")
54+
def test_print_formatted_text_backslash_r():
55+
f = _Capture()
56+
pt_print('hello\r\n', file=f)
57+
assert b'hello' in f.data
5258

5359
@pytest.mark.skipif(
5460
is_windows(), reason="Doesn't run on Windows yet.")

0 commit comments

Comments
 (0)
0