From 17a7a3b324ae74108781ad54ad106fac879ae692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Sun, 17 Mar 2019 18:39:06 +0100 Subject: [PATCH 1/2] Fix logic for quoting special characters --- 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 9561a827..94bc93bf 100644 --- a/lib/yaml/emitter.py +++ b/lib/yaml/emitter.py @@ -706,7 +706,7 @@ def analyze_scalar(self, scalar): if not (ch == u'\n' or u'\x20' <= ch <= u'\x7E'): if (ch == u'\x85' or u'\xA0' <= ch <= u'\uD7FF' or u'\uE000' <= ch <= u'\uFFFD' - or ((not has_ucs4) or (u'\U00010000' <= ch < u'\U0010ffff'))) and ch != u'\uFEFF': + or ((not has_ucs4) and (u'\U00010000' <= ch < u'\U0010ffff'))) and ch != u'\uFEFF': unicode_characters = True if not self.allow_unicode: special_characters = True From 93a0ae12b189a8d0e3924e6b7b71e7b8a6a5916c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Thu, 21 Mar 2019 23:30:21 +0100 Subject: [PATCH 2/2] Remove has_ucs4 from condition on systems with `sys.maxunicode <= 0xffff` the comparison (u'\U00010000' <= ch < u'\U0010ffff') can't be true anyway I think --- 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 94bc93bf..23c25ca8 100644 --- a/lib/yaml/emitter.py +++ b/lib/yaml/emitter.py @@ -706,7 +706,7 @@ def analyze_scalar(self, scalar): if not (ch == u'\n' or u'\x20' <= ch <= u'\x7E'): if (ch == u'\x85' or u'\xA0' <= ch <= u'\uD7FF' or u'\uE000' <= ch <= u'\uFFFD' - or ((not has_ucs4) and (u'\U00010000' <= ch < u'\U0010ffff'))) and ch != u'\uFEFF': + or (u'\U00010000' <= ch < u'\U0010ffff')) and ch != u'\uFEFF': unicode_characters = True if not self.allow_unicode: special_characters = True