From e8d79030f79375f704a9716e8be9c7b26a1e0a3f Mon Sep 17 00:00:00 2001 From: Joseph Marie Alba Date: Fri, 21 May 2021 15:44:33 +0800 Subject: [PATCH] fix: Python 3 issue on re (#13230) Python 3 interprets string literals as Unicode strings, and therefore \s and \g are treated as escaped Unicode characters. Fix: Declare RegEx pattern as a raw string instead by prepending r --- frappe/translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/translate.py b/frappe/translate.py index 1d8b1234c7..b9dd5e263a 100644 --- a/frappe/translate.py +++ b/frappe/translate.py @@ -650,7 +650,7 @@ def write_csv_file(path, app_messages, lang_dict): t = lang_dict.get(message, '') # strip whitespaces - translated_string = re.sub('{\s?([0-9]+)\s?}', "{\g<1>}", t) + translated_string = re.sub(r'{\s?([0-9]+)\s?}', r"{\g<1>}", t) if translated_string: w.writerow([message, translated_string, context])