gh-107715: Escape class name in regular expression#107716
Merged
serhiy-storchaka merged 2 commits intopython:mainfrom Aug 7, 2023
gertjanvanzwieten:doctest-escape-classname
Merged
gh-107715: Escape class name in regular expression#107716serhiy-storchaka merged 2 commits intopython:mainfrom gertjanvanzwieten:doctest-escape-classname
serhiy-storchaka merged 2 commits intopython:mainfrom
gertjanvanzwieten:doctest-escape-classname
Conversation
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.
2 tasks
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Contributor
Author
|
CLA signing fails repeatedly with internal server error, and the bedevere/news action does not appear to recognize the news entry. Edit: both issues seem to have resolved themselves. |
gertjanvanzwieten
added a commit
to evalf/nutils
that referenced
this pull request
Aug 7, 2023
This patch changes doctest's test finder to include all files in the nutils directory, rather than the ones listed in nutils.__all__ which is due to be removed. The change includes a modified version of DocTestFinder to fix a bug triggered by the SI module (formerly untested) and for which a PR is created for cpython (python/cpython#107716). The patch also includes a small fix in SI's documentation.
serhiy-storchaka
approved these changes
Aug 7, 2023
Contributor
|
Thanks @gertjanvanzwieten for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Contributor
|
Thanks @gertjanvanzwieten for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Aug 7, 2023
…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 <[email protected]>
|
GH-107726 is a backport of this pull request to the 3.12 branch. |
|
GH-107727 is a backport of this pull request to the 3.11 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Aug 7, 2023
…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 <[email protected]>
gertjanvanzwieten
added a commit
to evalf/nutils
that referenced
this pull request
Aug 7, 2023
This patch changes doctest's test finder to include all files in the nutils directory, rather than the ones listed in nutils.__all__ which is due to be removed. The change includes a modified version of DocTestFinder to fix a bug triggered by the SI module (formerly untested) and for which a fix is pending for cpython (python/cpython#107716). The patch also includes a small fix in SI's documentation.
serhiy-storchaka
pushed a commit
that referenced
this pull request
Aug 12, 2023
…GH-107727) 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 <[email protected]>
Yhg1s
pushed a commit
that referenced
this pull request
Aug 16, 2023
…#107726) * gh-107715: Escape class name in regular expression (GH-107716) 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 <[email protected]> * Update 2023-08-07-14-12-07.gh-issue-107715.238r2f.rst --------- Co-authored-by: Gertjan van Zwieten <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #107715. This patch escapes the class name before embedding it in the regular expression for
patindoctest.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 returnNonein this scenario, rather than potentially matching a different class or raisingre.errordepending on the symbols used.