]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Remove unnecessary compat shim 'binary_type'
authorJon Dufresne <jon.dufresne@gmail.com>
Thu, 11 Oct 2018 03:34:09 +0000 (20:34 -0700)
committerAarni Koskela <akx@iki.fi>
Thu, 24 Jan 2019 22:19:37 +0000 (00:19 +0200)
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

index 849f749e3970686b263e727a1432fadd912c3bf9..11b4d7a6b052938c411c5b81f50046aa53ee4ef2 100644 (file)
@@ -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)