https://github.com/python/cpython/commit/e745996b2d24b9234f896bdc2f3320e49287dcd0
commit: e745996b2d24b9234f896bdc2f3320e49287dcd0
branch: main
author: Marta Gómez Macías <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-07-13T10:44:18Z
summary:
gh-121609: Fix pasting of characters containing unicode character joiner
(#121667)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2024-07-13-09-51-44.gh-issue-121609.jWsE5t.rst
M Lib/_pyrepl/reader.py
M Lib/test/test_pyrepl/test_reader.py
diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py
index 63ae661968408e..1622d30dbba990 100644
--- a/Lib/_pyrepl/reader.py
+++ b/Lib/_pyrepl/reader.py
@@ -58,7 +58,6 @@ def disp_str(buffer: str) -> tuple[str, list[int]]:
elif unicodedata.category(c).startswith("C"):
c = r"\u%04x" % ord(c)
s.append(c)
- b.append(str_width(c))
b.extend([0] * (len(c) - 1))
else:
s.append(c)
diff --git a/Lib/test/test_pyrepl/test_reader.py
b/Lib/test/test_pyrepl/test_reader.py
index 986bc36d9a1070..e82c3ca0bb5cc2 100644
--- a/Lib/test/test_pyrepl/test_reader.py
+++ b/Lib/test/test_pyrepl/test_reader.py
@@ -88,6 +88,12 @@ def test_setpos_for_xy_simple(self):
reader.setpos_from_xy(0, 0)
self.assertEqual(reader.pos, 0)
+ def test_control_characters(self):
+ code = 'flag = "🏳️🌈"'
+ events = code_to_events(code)
+ reader, _ = handle_all_events(events)
+ self.assert_screen_equals(reader, 'flag = "🏳️\\u200d🌈"')
+
def test_setpos_from_xy_multiple_lines(self):
# fmt: off
code = (
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2024-07-13-09-51-44.gh-issue-121609.jWsE5t.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-13-09-51-44.gh-issue-121609.jWsE5t.rst
new file mode 100644
index 00000000000000..72b5c071a5c67b
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-13-09-51-44.gh-issue-121609.jWsE5t.rst
@@ -0,0 +1 @@
+Fix pasting of characters containing unicode character joiners in the new
REPL. Patch by Marta Gomez Macias
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]