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

EncodingWarning when building #561

Closed
jaraco opened this issue Nov 4, 2023 · 1 comment · Fixed by #577
Closed

EncodingWarning when building #561

jaraco opened this issue Nov 4, 2023 · 1 comment · Fixed by #577

Comments

@jaraco
Copy link
Contributor

jaraco commented Nov 4, 2023

While building using towncrier with PYTHONWARNDEFAULTENCODING=1, I see this warning:

/Users/jaraco/code/jaraco/jaraco.functools/.tox/finalize/lib/python3.11/site-packages/towncrier/build.py:169: EncodingWarning: 'encoding' argument not specified
  resources.files(config.template[0]).joinpath(config.template[1]).read_text()

One needs to explicitly pass encoding='utf-8' to .read_text() to avoid these warnings. See PEP 597 for details.

@adiroiban
Copy link
Member

Thanks. Good call.

I think that trial is missing a helper to catch generic warnings... but maybe we can have a quick hack and run our CI with the warnings enabled and just fail somehow is a warning is raised.

But event a PR with just the explicit encoding, and without any extra warning detection, is good enough.

Happy to review a PR.

jaraco added a commit to jaraco/towncrier that referenced this issue Feb 10, 2024
jaraco added a commit to jaraco/towncrier that referenced this issue Feb 10, 2024
jaraco added a commit to jaraco/towncrier that referenced this issue Feb 10, 2024
jaraco added a commit to jaraco/towncrier that referenced this issue Feb 10, 2024
adiroiban added a commit that referenced this issue Apr 28, 2024
* Add explicit encoding to read_text.

Closes #561

* Add explicit encoding in towncrier.create.

* Add note about UTF-8 encoding to tutorial.

* Expand the note to mention the fragments, the news file, the config file, and templates.

* Use 'utf-8' throughout for consistency.

---------

Co-authored-by: Adi Roiban <adiroiban@gmail.com>
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 a pull request may close this issue.

2 participants