Skip to content

Commit f0c0647

Browse files
committed
[3013559] cbook.get_sample_data: open image file in binary mode. Patch by C. Gohlke.
svn path=/trunk/matplotlib/; revision=8413
1 parent 7e247f6 commit f0c0647

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/cbook.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,11 @@ def get_sample_data(self, fname, asfileobj=True):
619619
fname = cached[0]
620620

621621
if asfileobj:
622-
return file(fname)
622+
if os.path.splitext(fname)[-1].lower() in ('.csv', '.xrc', '.txt'):
623+
mode = 'r'
624+
else:
625+
mode = 'rb'
626+
return open(fname, mode)
623627
else:
624628
return fname
625629

0 commit comments

Comments
 (0)