matplotlib/matplotlib — Issue #678: savefig to StringIO crashes
Author: vchahun
Created: 2012-01-16 23:35:19+00:00
State: open

Example code:

```python
import pylab, StringIO

out = StringIO.StringIO()
pylab.plot([1, 2, 3])
pylab.savefig(out, format = "svg")
```

Crashes here:
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_svg.py#L1067
`AttributeError: readable` (apparently, it expects an `io.StringIO` file object)

... but using `io.StringIO` crashes as well, with an unicode issue:
`TypeError: string argument expected, got 'str'`

The only workaround I have found so far consists in subclassing StringIO:

```python
class MyStringIO(StringIO):
def readable(self):
return True

def writable(self):
return True

def seekable(self):
return True
```