Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b11e2f

Browse files
committed
Merge pull request #3487 from mdboom/use-getcwdu
BUG : use getcwdu to deal with unicode in user home-path in python 2
2 parents cb36b28 + 0a41d83 commit 1b11e2f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/matplotlib/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,11 @@ def matplotlib_fname():
745745
- Lastly, it looks in `$MATPLOTLIBDATA/matplotlibrc` for a
746746
system-defined copy.
747747
"""
748-
fname = os.path.join(os.getcwd(), 'matplotlibrc')
748+
if six.PY2:
749+
cwd = os.getcwdu()
750+
else:
751+
cwd = os.getcwd()
752+
fname = os.path.join(cwd, 'matplotlibrc')
749753
if os.path.exists(fname):
750754
return fname
751755

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,10 @@ def run_code(code, code_path, ns=None, function_name=None):
447447
# Change the working directory to the directory of the example, so
448448
# it can get at its data files, if any. Add its path to sys.path
449449
# so it can import any helper modules sitting beside it.
450-
451-
pwd = os.getcwd()
450+
if six.PY2:
451+
pwd = os.getcwdu()
452+
else:
453+
pwd = os.getcwd()
452454
old_sys_path = list(sys.path)
453455
if setup.config.plot_working_directory is not None:
454456
try:

0 commit comments

Comments
 (0)