From e3e87055bd263aa152556900d40d98ffd847f41a Mon Sep 17 00:00:00 2001 From: HARSH SUMAN Date: Thu, 18 Dec 2025 17:22:20 +0530 Subject: [PATCH] Merge pull request #28195 from harsh-suman5:fix-coverage-regex Fix regex escape warning in _coverage.py by using raw string #2819 while i am running '_coverage.py' I noticed there is a syntax warning:"\." It is an invalid escape sequence The regex was written as a normal string with '\.' which is not valid escape in string literals and give problems and error in a new python versions. To fix this switch to raw string(r'cv2?\.\w+') which can passes the backslashes directly to the regex engine. This removes the warning and keeps the code and pattern working properly. This is a small fix but important for future compatibilities. --- samples/python/_coverage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/python/_coverage.py b/samples/python/_coverage.py index 62dd7aa5d8..634c6b8795 100755 --- a/samples/python/_coverage.py +++ b/samples/python/_coverage.py @@ -18,7 +18,7 @@ if __name__ == '__main__': for fn in glob('*.py'): print(' --- ', fn) code = open(fn).read() - found |= set(re.findall('cv2?\.\w+', code)) + found |= set(re.findall(r'cv2?\.\w+', code)) cv2_used = found & cv2_callable cv2_unused = cv2_callable - cv2_used