Repository: iterative/dvc
Issue: Unable to add files with unicode pathnames

System environment
------

### `dvc version`

```
DVC version: 0.59.2
Python version: 2.7.10
Platform: Darwin-18.7.0-x86_64-i386-64bit
Binary: False
Cache: hardlink - True, reflink - True, symlink - True
```

### `brew info dvc`

```
iterative/dvc/dvc: stable 0.59.2
Git for data science projects
https://dataversioncontrol.com/
/usr/local/Cellar/dvc/0.59.2 (10,442 files, 258MB) *
  Built from source on 2019-09-16 at 00:58:51
From: https://github.com/iterative/homebrew-dvc/blob/master/Formula/dvc.rb
==> Dependencies
Build: pkg-config ✔
Required: python ✔
```

Steps to reproduce
------

### Set up

```shell
$ mkdir test_dvc_unicode_filename
$ cd test_dvc_unicode_filename
$ git init
Initialized empty Git repository in /Users/bossliaw/test_dvc_unicode_filename/.git/

$ dvc init
Adding '.dvc/lock' to '.dvc/.gitignore'.
Adding '.dvc/config.local' to '.dvc/.gitignore'.
Adding '.dvc/updater' to '.dvc/.gitignore'.
Adding '.dvc/updater.lock' to '.dvc/.gitignore'.
Adding '.dvc/state-journal' to '.dvc/.gitignore'.
Adding '.dvc/state-wal' to '.dvc/.gitignore'.
Adding '.dvc/state' to '.dvc/.gitignore'.
Adding '.dvc/cache' to '.dvc/.gitignore'.

You can now commit the changes to git.

+---------------------------------------------------------------------+
|                                                                     |
|        DVC has enabled anonymous aggregate usage analytics.         |
|     Read the analytics documentation (and how to opt-out) here:     |
|              https://dvc.org/doc/user-guide/analytics               |
|                                                                     |
+---------------------------------------------------------------------+

What's next?
------------
- Check out the documentation: https://dvc.org/doc
- Get help and share ideas: https://dvc.org/chat
- Star us on GitHub: https://github.com/iterative/dvc
```

### Create a file with unicode pathname

```shell
$ mkdir 貓
$ echo "資料版本控制檔名測試" > 貓/貓貓貓.txt
$ git config core.quotePath false
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   .dvc/.gitignore
        new file:   .dvc/config

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        貓/
```

### Error when `dvc add`

```shell
$ dvc add 貓/
Adding '貓' to '.gitignore'.
ERROR: unexpected error - 'ascii' codec can't decode byte 0xe8 in position 42: ordinal not in range(128)

Having any troubles?. Hit us up at https://dvc.org/support, we are always happy to help!
```

After this step, all DVC commands are failing:

```shell
$ dvc status
ERROR: failed to obtain data status - 'ascii' codec can't decode byte 0xe8 in position 42: ordinal not in range(128)

Having any troubles?. Hit us up at https://dvc.org/support, we are always happy to help!
```

```shell
$ dvc destroy
ERROR: failed to obtain data status - 'ascii' codec can't decode byte 0xe8 in position 42: ordinal not in range(128)

Having any troubles?. Hit us up at https://dvc.org/support, we are always happy to help!
```

I didn't find any information about pathname encoding limitation, so I decided to report this issue.


Changed files:
dvc/main.py

diff --git a/dvc/main.py b/dvc/main.py
index 4c55862bf..6cb11baef 100644
--- a/dvc/main.py
+++ b/dvc/main.py
@@ -10,6 +10,7 @@ from dvc.config import ConfigError
 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")
@@ -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)