Replace basestring with str for python 3 compatibility.