From 54506fb1934f3f3ab7a19bfaf8bc67750505abf7 2020-05-29 19:53:29 From: Matthias Bussonnier Date: 2020-05-29 19:53:29 Subject: [PATCH] Merge pull request #12349 from meeseeksmachine/auto-backport-of-pr-12342-on-7.x Backport PR #12342 on branch 7.x (Fixed bug on windows where relative image path has wrong slashes) --- diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 0481624..3d5b376 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -419,8 +419,8 @@ class EmbeddedSphinxShell(object): # insert relative path to image file in source # as absolute path for Sphinx # sphinx expects a posix path, even on Windows - posix_path = pathlib.Path(savefig_dir,filename).as_posix() - outfile = '/' + os.path.relpath(posix_path, source_dir) + path = pathlib.Path(savefig_dir, filename) + outfile = '/' + path.relative_to(source_dir).as_posix() imagerows = ['.. image:: %s' % outfile]