-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-107715: Escape class name in regular expression #107716
gh-107715: Escape class name in regular expression #107716
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.
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
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. |
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.
Thanks @gertjanvanzwieten for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Thanks @gertjanvanzwieten for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…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>
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. |
…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>
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.
…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 <git@gjvz.nl>
…#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 <git@gjvz.nl> * Update 2023-08-07-14-12-07.gh-issue-107715.238r2f.rst --------- Co-authored-by: Gertjan van Zwieten <git@gjvz.nl> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Fixes #107715. This patch escapes the class name before embedding it in the regular expression for
pat
indoctest.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 returnNone
in this scenario, rather than potentially matching a different class or raisingre.error
depending on the symbols used.