Skip to content

Commit 0385c3d

Browse files
committed
fixed a bug in savefig, saving to a nonexistent directory
would result in a crash in some circumstances. Closes bug 1699614 svn path=/trunk/matplotlib/; revision=4649
1 parent 2c60848 commit 0385c3d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2007-12-06 fixed a bug in savefig, saving to a nonexistent directory
2+
would result in a crash in some circumstances. Closes bug
3+
1699614 - DSD
4+
15
2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD
26

37
===============================================================

lib/matplotlib/figure.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Figure class -- add docstring here!
33
"""
4+
import os
45
import sys
56

67
import numpy as npy
@@ -772,6 +773,9 @@ def savefig(self, *args, **kwargs):
772773
773774
format - one of the file extensions supported by the active backend.
774775
"""
776+
path = os.path.abspath(os.path.split(args[0])[0])
777+
if not os.access(path, os.W_OK):
778+
raise IOError('%s is not a writeable directory'%path)
775779

776780
for key in ('dpi', 'facecolor', 'edgecolor'):
777781
if not kwargs.has_key(key):

0 commit comments

Comments
 (0)