Skip to content

Commit

Permalink
Merge pull request iterative#2538 from mroutis/fix-2524
Browse files Browse the repository at this point in the history
py2: display friendly error when raising a UnicodeError
  • Loading branch information
efiop authored Sep 28, 2019
2 parents 22afc48 + 39dc79b commit 5c76b46
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from dvc.analytics import Analytics
from dvc.exceptions import NotDvcRepoError, DvcParserError
from dvc.remote.pool import close_pools
from dvc.utils.compat import is_py2


logger = logging.getLogger("dvc")
Expand Down Expand Up @@ -53,8 +54,14 @@ def main(argv=None):
ret = 253
except DvcParserError:
ret = 254
except Exception: # pylint: disable=broad-except
logger.exception("unexpected error")
except Exception as exc: # pylint: disable=broad-except
if isinstance(exc, UnicodeError) and is_py2:
logger.exception(
"unicode is not supported in DVC for Python 2 "
"(end-of-life January 1, 2020), please upgrade to Python 3"
)
else:
logger.exception("unexpected error")
ret = 255
finally:
logger.setLevel(outerLogLevel)
Expand Down

0 comments on commit 5c76b46

Please sign in to comment.