Unicode decode error

Correct the following exception on Windows with Py2.x and user having e.g. Umlaute in his home folder name.
twcbsrc.app_base - ERROR - app_base.pyo - 292 - Traceback (most recent call last):
  File "twcbsrc\controllers\app_cb.pyo", line 403, in onTBStats
  File "importlib\__init__.pyo", line 37, in import_module
  File "zipextimporter.pyo", line 82, in load_module
  File "twcbsrc\controllers\app_stats.pyo", line 29, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "twcbsrc\views\statistics.pyo", line 19, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "matplotlib\__init__.pyo", line 1048, in <module>
  File "matplotlib\__init__.pyo", line 897, in rc_params
  File "matplotlib\__init__.pyo", line 759, in matplotlib_fname
  File "matplotlib\__init__.pyo", line 630, in _get_configdir
  File "matplotlib\__init__.pyo", line 555, in _get_xdg_config_dir
  File "matplotlib\__init__.pyo", line 323, in wrapper
  File "matplotlib\__init__.pyo", line 509, in _get_home
  File "ntpath.pyo", line 310, in expanduser
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf6 in position 10: invalid start byte 

See also:  #3532

On 9/29/2014 20:42, Thomas A Caswell wrote:
>
> In lib/matplotlib/__init__.py:
>
> > @@ -523,7 +523,7 @@ def _get_home():
> >          http://mail.python.org/pipermail/python-list/2005-February/325395.html
> >      """
> >      try:
> > -        path = os.path.expanduser("~")
> > +        path = os.path.expanduser(b"~").decode(sys.getfilesystemencoding())
>
> I am a tad confused why this goes through a byte string
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/matplotlib/matplotlib/pull/3594/files#r18174163>.
>
I got the idea from a comment in this thread:
https://stackoverflow.com/questions/23888120/an-alternative-to-os-path-expanduser

If I correctly understand what is happening because I pass in b"~" 
expanduser returns a byte string, this can then be decoded using the 
filesystemencoding, if u"~" or just "~" is used then expanduser will 
convert using the sys.defaultencoding.

Hopefully someone with more Python know how then me can confirm that 
this is a valid approach - at least on Windows.