[Twisted-Python] Interface.adaptWith and Interface.__adapt__

Clark C. Evans cce at clarkevans.com
Sat Jun 7 12:51:49 MDT 2003


On Thu, Jun 05, 2003 at 09:00:25AM -0400, Phillip J. Eby wrote:
| >As I understand it, PEP 246 cannot be implemented without raising 
| >exceptions in __adapt__.
| 
| Actually, no.  __adapt__ is also allowed to return None to signal inability 
| to adapt.  And, the consensus so far of people I've talked with (Jim Fulton 
| and Guido) is that PEP 246 should be revised in that area anyway, such that 
| it isn't even an *option* to raise TypeError to signal 
| failure.  PyProtocols will only ignore TypeError if it looks like it came 
| from calling an unbound class method, not if it looks like it came from the 
| __conform__ or __adapt__ method body.

Phillip,

This is great that PEP 246 has found a supporter... let alone someone
who is doing an implementation!  Anyway, I support PEP 246 being 
modified to not catch TypeError; this was done in such a way as to
make writing adapters easier.  But alas, if setting up the try/catch
block is causing performance problems, then it should be dropped.

The python community does indeed need a common protocol implementation,
I do hope your work gains adoption.

Best,

Clark




More information about the Twisted-Python mailing list