This does not look right.

```
>>> some_bytes = b"Some bytes."
>>> str(some_bytes)
"b'Some bytes.'"
```
I think this should rather be:

```python
if hasattr(doc, 'decode'):
    doc = doc.decode('utf8')
lines[:] = doc.splitlines()
```