aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/lldbtest.py
diff options
context:
space:
mode:
authorDave Lee <davelee.com@gmail.com>2022-11-07 13:20:48 -0800
committerDave Lee <davelee.com@gmail.com>2022-11-07 19:33:57 -0800
commit7bf3cb3ee871b6707b7f5114a7fde61485df450e (patch)
tree71e7cd80382992c087516a3e01dfb51c3349fcc3 /lldb/packages/Python/lldbsuite/test/lldbtest.py
parent674a17e9bbe82e8c53952fd94dcd862b17cb2d2f (diff)
downloadllvm-7bf3cb3ee871b6707b7f5114a7fde61485df450e.zip
llvm-7bf3cb3ee871b6707b7f5114a7fde61485df450e.tar.gz
llvm-7bf3cb3ee871b6707b7f5114a7fde61485df450e.tar.bz2
[lldb] Fix issue with re.Pattern availability
`re.Pattern` is introduced in Python 3.7. To support Python 3.6, fallback to typechecking against `SRE_Pattern`. Differential Revision: https://reviews.llvm.org/D137582
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbtest.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 2d054f9..63bad9d 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -282,11 +282,14 @@ class ValueCheck:
test_base.assertSuccess(val.GetError())
+ # Python 3.6 doesn't declare a `re.Pattern` type, get the dynamic type.
+ pattern_type = type(re.compile(''))
+
if self.expect_name:
test_base.assertEqual(self.expect_name, val.GetName(),
this_error_msg)
if self.expect_value:
- if isinstance(self.expect_value, re.Pattern):
+ if isinstance(self.expect_value, pattern_type):
test_base.assertRegex(val.GetValue(), self.expect_value,
this_error_msg)
else:
@@ -296,7 +299,7 @@ class ValueCheck:
test_base.assertEqual(self.expect_type, val.GetDisplayTypeName(),
this_error_msg)
if self.expect_summary:
- if isinstance(self.expect_summary, re.Pattern):
+ if isinstance(self.expect_summary, pattern_type):
test_base.assertRegex(val.GetSummary(), self.expect_summary,
this_error_msg)
else: