FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-141174: Test `type_repr()` of `Template` with invalid syntax in `Interpolation` by dr-carlos · Pull Request #155661 · python/cpython · GitHub

/ cpython Public

gh-141174: Test type_repr() of Template with invalid syntax in Interpolation - #155661

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
dr-carlos:annolib-test-typerepr
Aug 13, 2026
Merged

gh-141174: Test type_repr() of Template with invalid syntax in Interpolation#155661
JelleZijlstra merged 1 commit into
python:mainfrom
dr-carlos:annolib-test-typerepr

Conversation

dr-carlos commented Aug 13, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Currently, there is no test in test_annotationlib.py of the following lines:

except SyntaxError:
return _template_to_ast_constructor(template)

These ensure that a reasonable value is returned when stringifying a Template annotation containing invalid syntax.

This could be tested for both get_annotations(format=Format.STRING) and type_repr(). But, it's impossible from a syntactic t-string and only possbile through artificial Template construction, which is only currently tested within the type_repr() tests. So I've only added a test there. Happy to add them in other places if that's required.

bedevere-app Bot added the tests Tests in the Lib/test dir label Aug 13, 2026
JelleZijlstra added skip news needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 13, 2026
JelleZijlstra enabled auto-merge (squash) August 13, 2026 14:18
JelleZijlstra merged commit 5cc9e46 into python:main Aug 13, 2026
58 checks passed

Copy link
Copy Markdown

Thanks @dr-carlos for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155711 is a backport of this pull request to the 3.15 branch.

bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 13, 2026

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155712 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2026
JelleZijlstra pushed a commit that referenced this pull request Aug 13, 2026
…x in `Interpolation` (GH-155661) (#155712)

gh-141174: Test `type_repr()` of `Template` with invalid syntax in `Interpolation` (GH-155661)

Test `type_repr()` of `Template` with invalid syntax in `Interpolation`
(cherry picked from commit 5cc9e46)

Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
… in `Interpolation` (python#155661)

Test `type_repr()` of `Template` with invalid syntax in `Interpolation`
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

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL