From: Jon Dufresne Date: Thu, 11 Oct 2018 03:34:09 +0000 (-0700) Subject: Remove unnecessary compat shim 'binary_type' X-Git-Tag: v2.7.0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4d834d4c1bffe05e71ee2ec21449b6b0b115e99;p=thirdparty%2Fbabel.git 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. --- 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)