pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

Signature email requires ASCII on Python 2 but requires Unicode only "str" on Python 3

Open jnrbsn opened this issue 6 years ago • 1 comments

Signature_init in signature.c currently uses the s format string for parsing the email argument. This is inconsistent between Python 2 and 3. On Python 2, it accepts either text (unicode) or bytes (str) and implicitly encodes text using the default system encoding, which is ascii by default (and it seems like changing it is kind of weird and not really recommended by most people). Python 3, it only accepts text (str), and it's implicitly encodes it using UTF-8.

The name argument for Signature_init just uses O and accepts either text or bytes. It appears to implicitly encode text using UTF-8 and leaves bytes as-is. I would expect the email argument to work the same way.

So there's currently no way to pass in bytes on Python 3 and no way to pass in non-ASCII text on Python 2.

jnrbsn avatar Aug 16 '19 22:08 jnrbsn

We don't support Python 2 any more.

Still we should handle the name and the email the same way. In my opinion the name should use s as well, and only accept text strings; but this would break code, so we should deprecate it first.

jdavid avatar Oct 26 '19 08:10 jdavid