From e7bcc0b283d9406a1140357c157c14c02bf9624b Mon Sep 17 00:00:00 2001 From: Jeremy Sanders Date: Mon, 5 Sep 2022 22:04:57 +0200 Subject: [PATCH] Fix encoding of r'\x' in strings Fixes github bug #404 --- toml/encoder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toml/encoder.py b/toml/encoder.py index bf17a72..6fe32c4 100644 --- a/toml/encoder.py +++ b/toml/encoder.py @@ -95,7 +95,8 @@ def _dump_str(v): if singlequote: v = v.replace("\\'", "'") v = v.replace('"', '\\"') - v = v.split("\\x") + # split on \x, but not \\x + v = re.split(r"(? 1: i = -1 if not v[0]: