-
-
Notifications
You must be signed in to change notification settings - Fork 213
fix: Fix unicode error on binary files #436
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
Conversation
If a unicode decode error is raised while trying to compile a file as a Jinja2 template, and the templates suffix is empty, we fallback to copying this file as is. Fixes #433.
Codecov Report
@@ Coverage Diff @@
## master #436 +/- ##
==========================================
- Coverage 96.33% 96.32% -0.02%
==========================================
Files 39 39
Lines 2456 2473 +17
==========================================
+ Hits 2366 2382 +16
- Misses 90 91 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost perfect, thanks 🙂
Please squash and merge, there's only one real commit, the rest are fixups. |
except UnicodeDecodeError: | ||
if self.template.templates_suffix: | ||
# suffix is not emtpy, re-raise | ||
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should raise a UserMessageError then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK as it is. That kind of exception would print a nice human-readable message in the CLI, but in this case I don't think we should hide the stack trace. If you add the .jinja
suffix to a binary file, it's a wrong usage of Copier and it should die badly, and the stack trace should tell you what's happening.
Let's see, if too many people open issues about that message not being understood, I think we can add it, but TBH I think it's too much of a corner case.
If a unicode decode error is raised
while trying to compile a file as a Jinja2 template,
and the templates suffix is empty,
we fallback to copying this file as is.
Fixes #433.