Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] gh-107715: Escape class name in regular expression (GH-107716) #107727

Merged
merged 2 commits into from Aug 12, 2023

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>
@cpython-cla-bot
Copy link

cpython-cla-bot bot 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
19 checks passed
@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.

None yet

4 participants