diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2020-10-06 14:39:13 -0400 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2020-10-06 14:39:13 -0400 |
| commit | ab0b14e8b2178160b1279d2a0679b8d9149cfe55 (patch) | |
| tree | c5f80ad16e026ea5506343263fa5ea961fd7ce70 /passlib/utils | |
| parent | f5da8e35044119040776cb5564d4a5f82de9928d (diff) | |
| download | passlib-ab0b14e8b2178160b1279d2a0679b8d9149cfe55.tar.gz | |
cleanup old python compat -- removed suppress_cause() and error_from() wrappers
Diffstat (limited to 'passlib/utils')
| -rw-r--r-- | passlib/utils/__init__.py | 2 | ||||
| -rw-r--r-- | passlib/utils/binary.py | 7 | ||||
| -rw-r--r-- | passlib/utils/compat/__init__.py | 14 |
3 files changed, 4 insertions, 19 deletions
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py index df4daf0..d6c61a0 100644 --- a/passlib/utils/__init__.py +++ b/passlib/utils/__init__.py @@ -65,7 +65,7 @@ from passlib.utils.compat import (add_doc, join_bytes, join_byte_values, join_byte_elems, join_unicode, unicode, byte_elem_value, unicode_or_str, unicode_or_bytes_types, - get_method_function, suppress_cause, PYPY) + get_method_function, PYPY) # local __all__ = [ # constants diff --git a/passlib/utils/binary.py b/passlib/utils/binary.py index e5bdf2b..813d5cc 100644 --- a/passlib/utils/binary.py +++ b/passlib/utils/binary.py @@ -20,7 +20,6 @@ from passlib import exc from passlib.utils.compat import ( bascii_to_str, iter_byte_chars, join_byte_values, join_byte_elems, - suppress_cause, unicode, unicode_or_bytes_types, ) from passlib.utils.decor import memoized_property @@ -156,7 +155,7 @@ def b64s_decode(data): try: data = data.encode("ascii") except UnicodeEncodeError: - raise suppress_cause(ValueError("string argument should contain only ASCII characters")) + raise ValueError("string argument should contain only ASCII characters") from None off = len(data) & 3 if off == 0: pass @@ -169,7 +168,7 @@ def b64s_decode(data): try: return a2b_base64(data) except _BinAsciiError as err: - raise suppress_cause(TypeError(err)) + raise TypeError(err) from None #============================================================================= # adapted-base64 encoding @@ -202,7 +201,7 @@ def ab64_decode(data): try: data = data.encode("ascii") except UnicodeEncodeError: - raise suppress_cause(ValueError("string argument should contain only ASCII characters")) + raise ValueError("string argument should contain only ASCII characters") from None return b64s_decode(data.replace(b".", b"+")) #============================================================================= diff --git a/passlib/utils/compat/__init__.py b/passlib/utils/compat/__init__.py index e582e0d..32cd777 100644 --- a/passlib/utils/compat/__init__.py +++ b/passlib/utils/compat/__init__.py @@ -178,20 +178,6 @@ def get_method_function(func): """given (potential) method, return underlying function""" return getattr(func, "__func__", func) -def error_from(exc, # *, - cause=None): - """ - backward compat hack to suppress exception cause in python3.3+ - - one python < 3.3 support is dropped, can replace all uses with "raise exc from None" - """ - exc.__cause__ = cause - exc.__suppress_context__ = True - return exc - -# legacy alias -suppress_cause = error_from - #============================================================================= # input/output #============================================================================= |
