From e4d834d4c1bffe05e71ee2ec21449b6b0b115e99 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 10 Oct 2018 20:34:09 -0700 Subject: [PATCH] Remove unnecessary compat shim 'binary_type' The bytes type is available on all supported Pythons. On Python 2, it is an alias of str, same as binary_type. By removing the shim, makes the code more forward compatible. --- babel/_compat.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/babel/_compat.py b/babel/_compat.py index 849f749e..11b4d7a6 100644 --- a/babel/_compat.py +++ b/babel/_compat.py @@ -8,7 +8,6 @@ _identity = lambda x: x if not PY2: text_type = str - binary_type = bytes string_types = (str,) integer_types = (int, ) @@ -33,7 +32,6 @@ if not PY2: else: text_type = unicode - binary_type = str string_types = (str, unicode) integer_types = (int, long) @@ -63,7 +61,7 @@ number_types = integer_types + (float,) def force_text(s, encoding='utf-8', errors='strict'): if isinstance(s, text_type): return s - if isinstance(s, binary_type): + if isinstance(s, bytes): return s.decode(encoding, errors) return text_type(s) -- 2.47.2