diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 25d7e04f3103..8a20272636f0 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -745,7 +745,11 @@ def matplotlib_fname(): - Lastly, it looks in `$MATPLOTLIBDATA/matplotlibrc` for a system-defined copy. """ - fname = os.path.join(os.getcwd(), 'matplotlibrc') + if six.PY2: + cwd = os.getcwdu() + else: + cwd = os.getcwd() + fname = os.path.join(cwd, 'matplotlibrc') if os.path.exists(fname): return fname diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py index 08093fe2a7ec..efc41f284dc8 100644 --- a/lib/matplotlib/sphinxext/plot_directive.py +++ b/lib/matplotlib/sphinxext/plot_directive.py @@ -447,8 +447,10 @@ def run_code(code, code_path, ns=None, function_name=None): # Change the working directory to the directory of the example, so # it can get at its data files, if any. Add its path to sys.path # so it can import any helper modules sitting beside it. - - pwd = os.getcwd() + if six.PY2: + pwd = os.getcwdu() + else: + pwd = os.getcwd() old_sys_path = list(sys.path) if setup.config.plot_working_directory is not None: try: