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

2007-07-17 Thread Nick Coghlan
Christian Heimes wrote: > What do you think about > > def write(self, s: str): > if self.closed: > raise ValueError("write to closed file") > try: > b = s.encode(self._encoding) > except AttributeError: > raise TypeError("str expected

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

2007-07-17 Thread Paul Moore
On 17/07/07, Christian Heimes <[EMAIL PROTECTED]> 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

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

2007-07-16 Thread Christian Heimes
Guido van Rossum wrote: > I came across this in your SF patch. I disagree with your desire to > let TextIOWrapper.write() handle bytes: it should *only* be passed str > objects. The uu test was failing because it was writing bytes to a > text stream. > > Perhaps the error should be better; though

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

2007-07-16 Thread Guido van Rossum
On 7/14/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > I'm having some troubles with unit tests in the py3k-struni branch. Some > test like test_uu are failing because an io.TextIOWrapper instance's > write() method doesn't handle bytes. The method is defined as: > > def write(self, s: str):

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

2007-07-14 Thread Christian Heimes
Hello! I'm having some troubles with unit tests in the py3k-struni branch. Some test like test_uu are failing because an io.TextIOWrapper instance's write() method doesn't handle bytes. The method is defined as: def write(self, s: str): if self.closed: raise ValueError("wr