Skip to content

Conversation

@anonrig
Copy link
Member

@anonrig anonrig commented May 29, 2024

The default value for encode and decode is utf-8. We don't need to explicitly define it.

@anonrig anonrig requested a review from bbayles May 29, 2024 02:11
@bbayles
Copy link
Collaborator

bbayles commented May 31, 2024

Hmm, I think this is premature / potentially incorrect for exotic systems. PEP 686 will make UTF-8 mode the default in 3.15, but that's not out yet and we support older versions of Python. Since Python 3.7 UTF-8 mode is on for most users, but you're an environment variable away from having it off.

@TkTech
Copy link

TkTech commented May 31, 2024

@bbayles That's only for the internals. encode/decode do indeed explicitly default to utf-8 since at least 3.8, which is the lowest version allowed by the pyproject.toml:

 str.encode(encoding="utf-8", errors="strict")

    Return an encoded version of the string as a bytes object. Default encoding is 'utf-8'.

and:

 bytes.decode(encoding="utf-8", errors="strict")
bytearray.decode(encoding="utf-8", errors="strict")

    Return a string decoded from the given bytes. Default encoding is 'utf-8'.

@bbayles
Copy link
Collaborator

bbayles commented May 31, 2024

I stand corrected, thanks.

@bbayles bbayles merged commit a7478cb into main May 31, 2024
@bbayles bbayles deleted the use-default-value branch May 31, 2024 19:41
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 this pull request may close these issues.

4 participants