summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/doctest.py2
-rw-r--r--Misc/NEWS.d/next/Library/2023-08-07-14-12-07.gh-issue-107715.238r2f.rst1
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 2776d74..a63df46 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1110,7 +1110,7 @@ class DocTestFinder:
if source_lines is None:
return None
pat = re.compile(r'^\s*class\s*%s\b' %
- getattr(obj, '__name__', '-'))
+ re.escape(getattr(obj, '__name__', '-')))
for i, line in enumerate(source_lines):
if pat.match(line):
lineno = i
diff --git a/Misc/NEWS.d/next/Library/2023-08-07-14-12-07.gh-issue-107715.238r2f.rst b/Misc/NEWS.d/next/Library/2023-08-07-14-12-07.gh-issue-107715.238r2f.rst
new file mode 100644
index 0000000..4bf08c0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-08-07-14-12-07.gh-issue-107715.238r2f.rst
@@ -0,0 +1 @@
+Fix :meth:`doctest.DocTestFinder.find` in presence of class names with special characters. Patch by Gertjan van Zwieten.