Skip to content

Conversation

@jdufresne
Copy link
Contributor

Now that the project is Python 3 only, the boundaries between bytes and
Unicode strings is more explicit.

This allows removing several unnecessary force_bytes() and
force_unicode() calls that handled differences between Python 2 and
Python 3. All uses of force_unicode() have been removed.

For values that are known to be bytes, use .decode() instead. For
values are that known to be str, use .encode() instead. This strategy
makes the type explicit and reduces a function call.

Key handling continues to use force_bytes() to allow callers to pass
either bytes or str.

To help enforce bytes/str handling in the future, the -b option is
passed to Python when testing. This option will emit a warning if bytes
and str are improperly mixed together.

Now that the project is Python 3 only, the boundaries between bytes and
Unicode strings is more explicit.

This allows removing several unnecessary force_bytes() and
force_unicode() calls that handled differences between Python 2 and
Python 3. All uses of force_unicode() have been removed.

For values that are known to be bytes, use `.decode()` instead. For
values are that known to be str, use `.encode()` instead. This strategy
makes the type explicit and reduces a function call.

Key handling continues to use force_bytes() to allow callers to pass
either bytes or str.

To help enforce bytes/str handling in the future, the `-b` option is
passed to Python when testing. This option will emit a warning if bytes
and str are improperly mixed together.
@jpadilla jpadilla added this to the v2.0.0 milestone Dec 17, 2020
@jpadilla jpadilla merged commit 97cd403 into jpadilla:master Dec 17, 2020
@jdufresne jdufresne deleted the force-bytes branch December 18, 2020 00:49
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.

3 participants