Replace 'basestring' by 'str' for Python 3 compatibility