From 0a8d23723848dc6493028f4b97177a931fe70736 Mon Sep 17 00:00:00 2001 From: Albert Siersema Date: Tue, 14 May 2019 15:28:43 +0200 Subject: [PATCH] Issue55222 (#55223) * Python 3.7 compatibility for re.Pattern (Fixes #55222) * Python 3.7 compatibility for re.Pattern (Fixes #55222) --- lib/ansible/module_utils/network/common/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/network/common/config.py b/lib/ansible/module_utils/network/common/config.py index d5c13bacb02..5bb12671497 100644 --- a/lib/ansible/module_utils/network/common/config.py +++ b/lib/ansible/module_utils/network/common/config.py @@ -41,6 +41,12 @@ DEFAULT_IGNORE_LINES_RE = set([ ]) +try: + Pattern = re._pattern_type +except AttributeError: + Pattern = re.Pattern + + class ConfigLine(object): def __init__(self, raw): @@ -162,7 +168,7 @@ class NetworkConfig(object): if ignore_lines: for item in ignore_lines: - if not isinstance(item, re._pattern_type): + if not isinstance(item, Pattern): item = re.compile(item) DEFAULT_IGNORE_LINES_RE.add(item)