From df4e10a36ff9a12d9567a3ae0f71040a2f82aad3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 30 Sep 2014 12:24:05 -0400 Subject: [PATCH] Merge pull request #3594 from wernerfb/UnicodeInitProblem BUG : Unicode decode error on with unicode username on py2+win --- lib/matplotlib/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 8a20272636f0..75582f2ad43e 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -506,7 +506,10 @@ def _get_home(): :see: http://mail.python.org/pipermail/python-list/2005-February/325395.html """ try: - path = os.path.expanduser("~") + if six.PY2 and sys.platform == 'win32': + path = os.path.expanduser(b"~").decode(sys.getfilesystemencoding()) + else: + path = os.path.expanduser("~") except ImportError: # This happens on Google App Engine (pwd module is not present). pass