]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121609: Fix pasting of characters containing unicode character joiner (#121667)
authorMarta Gómez Macías <mgmacias@google.com>
Sat, 13 Jul 2024 10:44:18 +0000 (12:44 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2024 10:44:18 +0000 (10:44 +0000)
Lib/_pyrepl/reader.py
Lib/test/test_pyrepl/test_reader.py
Misc/NEWS.d/next/Core_and_Builtins/2024-07-13-09-51-44.gh-issue-121609.jWsE5t.rst [new file with mode: 0644]

index 63ae661968408e0e697bffbcbecd1e87135c35ea..1622d30dbba9909686a00a79f5b2abd8cd6a3ea7 100644 (file)
@@ -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)
index 986bc36d9a1070bb72598181772ef25c149551b9..e82c3ca0bb5cc27ec9432128b8562ac56cc8afeb 100644 (file)
@@ -88,6 +88,12 @@ class TestReader(TestCase):
         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 (file)
index 0000000..72b5c07
--- /dev/null
@@ -0,0 +1 @@
+Fix pasting of characters containing unicode character joiners in the new REPL. Patch by Marta Gomez Macias