-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve object handling & testing of
ensure_unicode
(#9059)
* Use `elif` for `decode` in `ensure_unicode` * Handle Python Buffer Protocol in `ensure_unicode` Any other arbitrary object (like `bytearray` or `memoryview` based objects) can be decoded to `unicode` via `codecs.decode`. This is analogous to what is done in `ensure_bytes`. So handle this case here. If this also fails, then raise as usual. * Include `ensure_unicode` tests for various objects * Clarify error messages * Use `uint8` in `array` tests This is more consistent with the other tests, which also use this type. Though `int8` also works. * Pass `bytes` directly to `array` Appears this already gets interpreted correctly by `array`. Should also make the code easier to read for other maintainers. * Use `from array import array` Avoids the `array.array` bit which is a tad verbose.
- Loading branch information
Showing
2 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters