From c59740385da47b4548e907de21c84d63bd015d45 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Thu, 21 Jul 2016 22:34:24 +0530 Subject: [PATCH] zerver/lib/str_utils.py: Replace ValueError by TypeError. When a parameter of a wrong type is passed to a `force_*` method in str_utils.py, raise a TypeError. --- zerver/lib/str_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/lib/str_utils.py b/zerver/lib/str_utils.py index 26e2672f24..6c096b6326 100644 --- a/zerver/lib/str_utils.py +++ b/zerver/lib/str_utils.py @@ -45,7 +45,7 @@ def force_text(s, encoding='utf-8'): elif isinstance(s, binary_type): return s.decode(encoding) else: - raise ValueError("force_text expects a string type") + raise TypeError("force_text expects a string type") def force_bytes(s, encoding='utf-8'): # type: (Union[text_type, binary_type], str) -> binary_type @@ -55,7 +55,7 @@ def force_bytes(s, encoding='utf-8'): elif isinstance(s, text_type): return s.encode(encoding) else: - raise ValueError("force_bytes expects a string type") + raise TypeError("force_bytes expects a string type") def force_str(s, encoding='utf-8'): # type: (Union[text_type, binary_type], str) -> str @@ -67,7 +67,7 @@ def force_str(s, encoding='utf-8'): elif isinstance(s, binary_type): return s.decode(encoding) else: - raise ValueError("force_str expects a string type") + raise TypeError("force_str expects a string type") def dict_with_str_keys(dct, encoding='utf-8'): # type: (Mapping[NonBinaryStr, Any], str) -> Dict[str, Any]