replacing redundant code by _tmp_filename() function
string type testing via isinstance(s, basestring)