From ae08d8e56a2c7ddfdd33308467257b326fcfc910 Mon Sep 17 00:00:00 2001 From: Kadir Can Ozden <101993364+bysiber@users.noreply.github.com> Date: Fri, 20 Feb 2026 12:51:37 +0300 Subject: [PATCH] Fix off-by-one excluding U+10FFFF from valid Unicode range in emitter The supplementary plane range check in analyze_scalar uses strict less-than (< U+10FFFF) instead of less-than-or-equal (<= U+10FFFF). This excludes U+10FFFF, a valid Unicode code point per the YAML spec's c-printable production, causing it to be treated as a special character and unnecessarily forcing double-quoted style. The reader module correctly includes U+10FFFF in its acceptance range. --- lib/yaml/emitter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yaml/emitter.py b/lib/yaml/emitter.py index a664d0111..7412f6807 100644 --- a/lib/yaml/emitter.py +++ b/lib/yaml/emitter.py @@ -699,7 +699,7 @@ def analyze_scalar(self, scalar): if not (ch == '\n' or '\x20' <= ch <= '\x7E'): if (ch == '\x85' or '\xA0' <= ch <= '\uD7FF' or '\uE000' <= ch <= '\uFFFD' - or '\U00010000' <= ch < '\U0010ffff') and ch != '\uFEFF': + or '\U00010000' <= ch <= '\U0010ffff') and ch != '\uFEFF': unicode_characters = True if not self.allow_unicode: special_characters = True