Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-132661: Disallow Template/str concatenation after PEP 750 spec update #135996

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

davepeck
Copy link
Contributor

@davepeck davepeck commented Jun 26, 2025

Following the steering council decision and corresponding update to PEP750, we are removing support for both implicit and explicit Template/str concatenation.

@lysnikolaou I took a first pass at this, but it's still just a draft. I deleted the obvious code and updated our tests. But there's still more to clean up, both in action_helpers.c/_PyPegen_concatenate_strings (I just raised a syntax error if templates/non-templates were mixed, rather than cleaning up code that now supports more than it needs to), and probably in _ast_unparse.py amongst others. Happy to do this with your input, or happy to hand it off to you!

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -1902,6 +1907,7 @@ _PyPegen_concatenate_strings(Parser *p, asdl_expr_seq *strings,
}
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change :)

Py_TYPE(right)->tp_name);
return NULL;
}
PyErr_Format(PyExc_TypeError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use %T to format object's type.

combined = t1 + ", world"
self.assertTStringEqual(combined, ("Hello, world",), ())
self.assertEqual(fstring(combined), "Hello, world")
with self.assertRaises(TypeError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it make sense to check error message here?

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.

2 participants