From 521968e72b40af06a2e3aeebc8f318515ea5d5c7 Mon Sep 17 00:00:00 2001 From: "hasnain2808@gmail.com" Date: Fri, 5 Feb 2021 21:54:12 +0530 Subject: [PATCH] fix: trailing spaces match only when re compile --- frappe/core/doctype/doctype/doctype.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 80a576230c..b3878f2b36 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -669,7 +669,8 @@ class DocType(Document): flags = {"flags": re.ASCII} if six.PY3 else {} # a DocType name should not start or end with an empty space - if re.match("^[ \t\n\r]+|[ \t\n\r]+$", name, **flags): + lead_trail_whitespace_re = re.compile("^[ \t\n\r]+|[ \t\n\r]+$", **flags) + if lead_trail_whitespace_re.findall(name): frappe.throw(_("DocType's name should not start or end with whitespace"), frappe.NameError) # a DocType's name should not start with a number or underscore