Description
Bug report
Checklist
- I am confident this is a bug in CPython, not a bug in a third-party project
- I have searched the CPython issue tracker, and am confident this bug has not been reported before
A clear and concise description of the bug
Doctests initialization may fail with re.error
in case a module contains (dynamically generated) class objects with special characters in their name. This is caused by the regular expression compiled in doctest.DocTestFinder._find_lineno
failing to escape the class name before embedding it. If compilation does succeed, then invalid matches may result from interpreting the class name as a search pattern.
Your environment
- CPython versions tested on: 3.9.2
- Operating system and architecture: Debian linux amd64