[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    RE: [PyKDE] Bug khtml.Node.parentNode() ?
From:       Jim Bublitz <jbublitz () nwinternet ! com>
Date:       2003-04-18 22:13:13
[Download RAW message or body]

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

_______________________________________________
PyKDE mailing list    PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic