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, got %r" % s)
>         ...

The try/except here is a bit too broad - you only want to trap the 
attribute error.

That said, I'm not sure what error you could raise that would be clearer 
than complaining that the object passed in doesn't have an encode() method.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to