diff options
| author | Tomaz Solc <tomaz.solc@tablix.org> | 2021-01-08 16:26:30 +0100 |
|---|---|---|
| committer | Tomaz Solc <tomaz.solc@tablix.org> | 2021-01-08 16:26:30 +0100 |
| commit | 80625ee2a67c9654230bc0617c8911a3d26ea16c (patch) | |
| tree | 971626830b7fac434e3058f191aa86aaec75e17a /unidecode/__init__.py | |
| parent | 2f5e019513543a51d8f1ce5a3a70f2e5e22d9861 (diff) | |
| download | unidecode-80625ee2a67c9654230bc0617c8911a3d26ea16c.tar.gz | |
Avoid exception chaining on Python 3.
This avoids exceptions raised by errors='strict' from displaying as
"During handling of the above exception ..." in the backtrace which
can be confusing.
Diffstat (limited to 'unidecode/__init__.py')
| -rw-r--r-- | unidecode/__init__.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/unidecode/__init__.py b/unidecode/__init__.py index 54c543d..776d6e4 100644 --- a/unidecode/__init__.py +++ b/unidecode/__init__.py @@ -65,11 +65,14 @@ def unidecode_expect_ascii(string, errors='ignore', replace_str='?'): try: bytestring = string.encode('ASCII') except UnicodeEncodeError: - return _unidecode(string, errors, replace_str) - if version_info[0] >= 3: - return string + pass else: - return bytestring + if version_info[0] >= 3: + return string + else: + return bytestring + + return _unidecode(string, errors, replace_str) def unidecode_expect_nonascii(string, errors='ignore', replace_str='?'): """Transliterate an Unicode object into an ASCII string |
