[Python-3000] TextIOWrapper.write(s:str) and bytes in py3k-struni (original) (raw)

Paul Moore p.f.moore at gmail.com
Tue Jul 17 13:04:13 CEST 2007


On 17/07/07, Christian Heimes <lists at cheimes.de> wrote:

def write(self, s: str): if self.closed: raise ValueError("write to closed file") if not hasattr(s, 'encode') raise TypeError("str expected, got %r" % s) ...

? It explains what is going wrong.

Surely the error should say that the object passed needs an encode method, rather than that it should be a str?

Paul.



More information about the Python-3000 mailing list