]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-121609: Fix pasting of characters containing unicode character joiner ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 14 Jul 2024 09:02:46 +0000 (11:02 +0200)
committerGitHub <noreply@github.com>
Sun, 14 Jul 2024 09:02:46 +0000 (03:02 -0600)
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
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 4431b6a324e73aaf892c65a4d7ca8e2ff1118a65..5d83ce4df0d49f05c1a6ff6d39c229bca616662b 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 78b11323d60a852db95855c62d3534481b00e91a..c09838f3260650713dadadb5523515c66cdb3e9b 100644 (file)
@@ -89,6 +89,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