Skip to content
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

PackageLoader raises misleading error when template directory does not exist. #1995

Open
elektito opened this issue Jun 6, 2024 · 2 comments

Comments

@elektito
Copy link

elektito commented Jun 6, 2024

When using PackageLoader and the template directory does not exist, it throws an error saying:

The 'foobar' package was not installed in a way that PackageLoader understands.

This is clearly incorrect. If the package is actually not there, we get an assertion error. I would say the error should be something like "Template directory was not found in package 'foobar'." or something along those lines.

Describe how to replicate the bug.
Just create a package without the template directory. Try to pass that name of the package to PackageLoader causes the incorrect error to be thrown.

I hope this is not considered too trivial. It did cost me some time to figure out, and only after reading the source code, so I think it's worth changing to something that makes the root cause more apparent.

Environment:

  • Python version: 3.10.12
  • Jinja version: 3.1.4
@davidism
Copy link
Member

davidism commented Jun 6, 2024

Happy to review a PR

@elektito
Copy link
Author

elektito commented Jun 6, 2024

Done!

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

No branches or pull requests

2 participants