[lxml-dev] objectify.ObjectPath("wrongroot.a.b")(root, None) should not raise an exception

Hi, using an absolute ObjectPath with a wrong root element objectify.ObjectPath("wrongroot.a.b")(root, None) currently raises ValueError even if a default is given: >>> root = objectify.fromstring("<root><a><b>23</b></a></root>")
objectify.ObjectPath("root.a.b")(root, None) 23 objectify.ObjectPath("wrongroot.a.b")(root, None) Traceback (most recent call last): File "<stdin>", line 1, in ? File "objectpath.pxi", line 53, in lxml.objectify.ObjectPath.__call__ File "objectpath.pxi", line 197, in lxml.objectify._findObjectPath ValueError: root element does not match: need wrongroot, got root
Whereas ObjectPath returns a given default if any other element of the path is not in the tree: >>> objectify.ObjectPath("root.wronga.b")(root, None)
I'll change this in trunk to gracefully return the default, and add some tests
(unless someone stops me... :) Holger -- Psssst! Schon das coole Video vom GMX MultiMessenger gesehen? Der Eine für Alle: http://www.gmx.net/de/go/messenger03

Hi, Holger Joukl wrote:
using an absolute ObjectPath with a wrong root element currently raises ValueError even if a default is given: [...] Whereas ObjectPath returns a given default if any other element of the path is not in the tree:
I'll change this in trunk to gracefully return the default, and add some tests
Please do. Stefan

I'll change this in trunk to gracefully return the default, and add some tests
Please do.
Committed revision 57527, Holger -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx
participants (3)
-
Holger Joukl
-
jholg@gmx.de
-
Stefan Behnel