Fixed #35571 -- Store template_names as string #18331
Closed
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.
Trac ticket number
ticket-35571
Branch description
When passing pathlib.Path or pathlib.PosixPath as template names (because templates are in subdirectories, so pathlib seems reasonable to use) the assertTemplateUsed breaks as it performs a str.join on all template names without sanitizing them.
This causes a lot of confusion as it is quite hard to track down the Template that introduced the PosixPath.
This is one proposed solution for fixing this. I.e. trying to sanitize all template names when they are passed into the template engine, as this seems easier then trying to find all cases where the stringiness of the template name is assumed. Another approach would be to have an assert that the template name is a string, but this could possible break code that doesn't utilize the test framework.
Checklist
main
branch.