Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 72a8ec4

Browse filesBrowse files
committed
Handling potential plot_working_directory errors
Handling potential invalid directory path and invalid type errors.
1 parent e8a18a1 commit 72a8ec4
Copy full SHA for 72a8ec4

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,16 @@ def run_code(code, code_path, ns=None, function_name=None):
466466
pwd = os.getcwd()
467467
old_sys_path = list(sys.path)
468468
if setup.config.plot_working_directory is not None:
469-
os.chdir(setup.config.plot_working_directory)
469+
try:
470+
os.chdir(setup.config.plot_working_directory)
471+
except OSError as err:
472+
raise OSError(str(err) + '\n`plot_working_directory` option in'
473+
'Sphinx configuration file must be a valid '
474+
'directory path')
475+
except TypeError as err:
476+
raise TypeError(str(err) + '\n`plot_working_directory` option in '
477+
'Sphinx configuration file must be a string or '
478+
'None')
470479
sys.path.insert(0, setup.config.plot_working_directory)
471480
elif code_path is not None:
472481
dirname = os.path.abspath(os.path.dirname(code_path))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.