This should be ``isinstance(t, basestring)`` and you should add the following at the top of the file for Python 3 compatability:

```python
if sys.version_info[0] >= 3:
    basestring = str
```