[Lldb-commits] [lldb] [lldb][test] Remove Python <= 3.6 workaround (PR #215262)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 10 05:39:36 PDT 2026
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/215262
>From 7982082dece3ca2b250f7d1752ffb205b6d9d764 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at arm.com>
Date: Mon, 10 Aug 2026 12:33:14 +0000
Subject: [PATCH 1/2] [lldb][test] Remove Python <= 3.6 workaround
re.Pattern was added in 3.7 and our minimum
is now 3.8.
Python 3.6.15:
>>> import re
>>> re.Pattern
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 're' has no attribute 'Pattern'
Python 3.7.17:
>>> import re
>>> re.Pattern
<class 're.Pattern'>
Python 3.8.20:
>>> import re
>>> re.Pattern
<class 're.Pattern'>
(it does not appear in documentation until 3.11)
---
lldb/packages/Python/lldbsuite/test/decorators.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 6524d73e4a349..eab8c16be47fa 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -104,9 +104,7 @@ def _match_decorator_property(expected, actual):
if isinstance(expected, no_match):
return not _match_decorator_property(expected.item, actual)
- # Python 3.6 doesn't declare a `re.Pattern` type, get the dynamic type.
- pattern_type = type(re.compile(""))
- if isinstance(expected, (pattern_type, str)):
+ if isinstance(expected, (re.Pattern, str)):
return re.search(expected, actual) is not None
if hasattr(expected, "__iter__"):
>From f741e5e89255e4ac4167590ab2adf4027b3361d2 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at arm.com>
Date: Mon, 10 Aug 2026 12:38:23 +0000
Subject: [PATCH 2/2] more instances of this
---
lldb/packages/Python/lldbsuite/test/lldbtest.py | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index a78c11c5752d5..2503df89bd28e 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -347,13 +347,10 @@ def check_value(self, test_base, val, error_msg=""):
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, pattern_type):
+ if isinstance(self.expect_value, re.Pattern):
test_base.assertRegex(val.GetValue(), self.expect_value, this_error_msg)
else:
test_base.assertEqual(self.expect_value, val.GetValue(), this_error_msg)
@@ -362,7 +359,7 @@ def check_value(self, test_base, val, error_msg=""):
self.expect_type, val.GetDisplayTypeName(), this_error_msg
)
if self.expect_summary:
- if isinstance(self.expect_summary, pattern_type):
+ if isinstance(self.expect_summary, re.Pattern):
test_base.assertRegex(
val.GetSummary(), self.expect_summary, this_error_msg
)
More information about the lldb-commits
mailing list