Closed
Description
To reproduce, run the following script (in master, on Python 2.7):
import matplotlib
matplotlib.use('webagg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
ERROR:tornado.application:Uncaught exception GET /1/download.jpeg (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:8988', method='GET', uri='/1/download.jpeg', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Connection': 'keep-alive', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Referer': 'http://127.0.0.1:8988/', 'Host': '127.0.0.1:8988', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0'})
Traceback (most recent call last):
File "/home/afrl/anaconda/lib/python2.7/site-packages/tornado/web.py", line 1332, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/home/afrl/workspace/matplotlib/lib/matplotlib/backends/backend_webagg.py", line 201, in get
manager.canvas.print_figure(buff, format=fmt)
File "/home/afrl/workspace/matplotlib/lib/matplotlib/backend_bases.py", line 2216, in print_figure
**kwargs)
File "/home/afrl/workspace/matplotlib/lib/matplotlib/backends/backend_agg.py", line 581, in print_jpg
return image.save(filename_or_obj, format='jpeg', **options)
File "/home/afrl/anaconda/lib/python2.7/site-packages/PIL/Image.py", line 1439, in save
save_handler(self, fp, filename)
File "/home/afrl/anaconda/lib/python2.7/site-packages/PIL/JpegImagePlugin.py", line 471, in _save
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
File "/home/afrl/anaconda/lib/python2.7/site-packages/PIL/ImageFile.py", line 476, in _save
fh = fp.fileno()
UnsupportedOperation: fileno
ERROR:tornado.access:500 GET /1/download.jpeg (127.0.0.1) 27.78ms
It looks like PIL
is looking for a fileno
attribute on the object but the io.BytesIO
obj passed by backend_webagg
has no fileno
.