You think that fname contains a string but in fact, the way you have structured your previous code, fname is somehow being assigned None. That is why we are asking to see some more code.
>>> open(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: coercing to Unicode: need string or buffer, NoneType found
You'll have to fix how you set fname or explicitly guard against it being None.
NoneNone. That is why we are asking to see some more code.