KEMBAR78
[3.11] gh-107715: Escape class name in regular expression (GH-107716) by miss-islington · Pull Request #107727 · python/cpython · GitHub
Skip to content

Conversation

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Aug 7, 2023

This patch escapes the class name before embedding it in the regular expression
for pat in doctest.DocTestFinder._find_lineno. While class names do not
ordinarily contain special characters, it is possible to encounter these when a
class is created dynamically. Escaping the name will correctly return None in
this scenario, rather than potentially matching a different class or raising
re.error depending on the symbols used.
(cherry picked from commit 8579327)

Co-authored-by: Gertjan van Zwieten git@gjvz.nl

…7716)

This patch escapes the class name before embedding it in the regular expression
for `pat` in `doctest.DocTestFinder._find_lineno`. While class names do not
ordinarily contain special characters, it is possible to encounter these when a
class is created dynamically. Escaping the name will correctly return `None` in
this scenario, rather than potentially matching a different class or raising
`re.error` depending on the symbols used.
(cherry picked from commit 8579327)

Co-authored-by: Gertjan van Zwieten <git@gjvz.nl>
@ghost
Copy link

ghost commented Aug 7, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) August 7, 2023 15:27
@serhiy-storchaka serhiy-storchaka merged commit 5f36e5c into python:3.11 Aug 12, 2023
@miss-islington miss-islington deleted the backport-8579327-3.11 branch August 12, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants