[PyKDE] Bug khtml.Node.parentNode() ?
Jim Bublitz
jbublitz at nwinternet.com
Sat Apr 19 00:30:00 BST 2003
On 18-Apr-03 Mateusz Korniak wrote:
> According to
> http://www.riverbankcomputing.co.uk/pykde/docs/none.html
> C++ NULL is converted to None
> but in example below khtml.Node.parentNode() returns Node when
> (IMHO) should
> return None. Shortly after program crashes.
> Problem is always reproducable on my machine. Just run click any
> item on html page. I'm I wrong or is it bug ?
The code seems to work if you change:
while 1:
to:
while not node.parentNode ().isNull ():
(although there's probably a more elegant/efficient way to
implement the same test).
Note that the docs don't exactly say parentNode() will return NULL
(or None in Python), but just that the parent might *be* NULL.
Here's the underlying C++ code:
Node Node::parentNode() const
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
return impl->parentNode();
}
bool Node::isNull() const
{
return (impl == 0);
}
Since isNull() returns 1 just before the crash, it's safe to say
impl == 0. When that's true, parentNode() throws a C++ exception
which *doesn't* propagate into Python, and the crash happens.
impl is of type NodeImpl, which is the internal implementation of
the Node class and isn't exposed in the Python bindings (most of
the khtml and kjs classes are written that way).
> 2. I'm not sure if it is right place to post such bugs ?
This is the right place.
I like the look of the web page, even if I can't read Polish.
Jim
More information about the PyQt
mailing list