question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UTF-8 author name leads to Author-email field being encoded

See original GitHub issue

I have a pyproject.toml containing my name and email in the authors field like this:

authors = [
  { name = "Gina Häußge", email = "gina@octoprint.org" }
]

Running python -m build generates the following in METADATA:

Author-email: =?utf-8?b?R2luYSBIw6R1w59nZSA8Z2luYUBvY3RvcHJpbnQub3JnPg==?=

That in turn leads to an error when attempting to upload such a package to testpypi (I haven’t yet tried production pypi but I would expect it to behave exactly the same):

❯ python -m twine upload --repository testpypi dist/*
[...]
ERROR    HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
         '=?utf-8?b?R2luYSBIw6R1w59nZSA8Z2luYUBvY3RvcHJpbnQub3JnPg==?=' is an invalid value for Author-email. Error: Use a valid email address See https://packaging.python.org/specifications/core-metadata for more      
         information.

Should this maybe rather be =?utf-8?b?R2luYSBIw6R1w59nZQ==?= <gina@octoprint.org> in that Author-email field? Or maybe, given that Core metadata specifications says this:

Whenever metadata is serialised to a byte stream (for example, to save to a file), strings must be serialised using the UTF-8 encoding.

just leaving UTF-8 strings as is and including them in the file unencoded would be the best way, but I don’t know what side effects that might have.

In my setup.py based packages, METADATA looks like this and that works just fine on upload:

Author: =?utf-8?b?R2luYSBIw6R1w59nZQ==?=
Author-email: gina@octoprint.org

So, if push comes to shove, splitting the values up like this might be the easiest solution to this issue, as already mentioned in #501. Being forced to write my name ASCII only certainly feels wrong in 2022 😉

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FFY00commented, Nov 9, 2022

No worries, happy to help 😊

0reactions
fooselcommented, Nov 9, 2022

Ah, thanks, yes, that wheel ticket looks very much like it.

For reference, my build system definition:

[build-system]
requires = [
    "setuptools>=40.8.0",
    "wheel"
]
build-backend = "setuptools.build_meta"

And apologies, I’m still getting my bearings with the fancy new stuff after coming from a decade of setup.py 😃

In that case, happy to close this and sub to the wheel issue instead, thanks and apologies for the noise!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"=?utf-8?Q?" in e-mail From field, caused by ... - OutSystems
It's actually not an problem with the EmailAddressCreate but with the "From" field that is incorrectly double encoding the name just before the...
Read more >
Site name is not UTF-8 encoded in email headers - Drupal
As soon as your Drupal site name is composed of non-ASCII characters, the "From" header is causing trouble.
Read more >
Core metadata email fields & Unicode - Packaging
The core metadata spec says that both Author-email and Maintainer-email “can contain a name and e-mail address in the legal forms for a ......
Read more >
Python DictWriter writing UTF-8 encoded CSV files
DictWriter can write a list of dictionaries into a CSV file. I want the CSV file to be encoded in UTF8. The csv...
Read more >
Header Entry (GNU gettext utilities)
... TITLE", "YEAR" and "FIRST AUTHOR <EMAIL@ADDRESS>, YEAR" ought to be ... with the character encoding used for your language, in your locale,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found