[lxml-dev] Explicit type checking and zope.security

Stefan Behnel stefan_ml at behnel.de
Mon Feb 18 14:15:27 CET 2008


Hi,

Christian Zagrodnick wrote:
> lxml does quite some explicit type checking. For instance:
> 
>     object_path.addattr(root, value)
> 
> gives me an error if root is security proxied:
> 
>       File "objectpath.pxi", line 74, in lxml.objectify.ObjectPath.addattr
>     TypeError: Argument 'root' has incorrect type (expected 
> lxml.etree._Element, got zope.security._proxy._Proxy)
> 
> Is this explicit checking really necessary? It's quite annoying to have
> to unwrap everything (and eventually check manually for security) 
> before putting it into lxml's hands.

You would get a crash if lxml didn't check the type. _Element objects are
proxies that contain a pointer to the C struct of a libxml2 node, so passing a
wrapper won't work.

Stefan



More information about the lxml-dev mailing list