bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: python (parted) question


From: Andrew Clausen
Subject: Re: python (parted) question
Date: Thu, 18 Sep 2003 10:13:23 +1000
User-agent: Mutt/1.5.4i

On Wed, Sep 17, 2003 at 11:24:15AM -0700, Paul Telford wrote:
> 
> [ removed debian-python from CC list, as i think it is offtopic for them 
> by this point ]
> 
> On Fri, 12 Sep 2003, Andrew Clausen wrote:
> 
> > So, to begin... could you stick a ped_disk_print((PedDisk*)o->obj)
> > call in the above function?
> 
> Thanks, I did as you suggested, which gave me some clues and led to some
> further printf's as I traced back the problem.  I now think the problem is
> first occuring with ped_disk_add_partition().  I have code that looks
> like:
> 
>         foo = ped_disk_add_partition((PedDisk *)o->obj,((PedPartition 
> *)o2->obj),
>                     ped_constraint_any((PedDevice *)o->obj));
> 
> This line is from python-parted (the distributed version does not check
> the return code of that function though, which I think is dangerous).  
> After the above, foo == 0.  I added in a printf above that line as
> follows:

If foo == 0, then I'd expect an exception to have been thrown.
You might want to set a breakpoint on ped_exception_throw to see what
it is.  (Also, python-parted should have set an exception handler...
maybe that has useful information?)

> 
>         printf("o = %s, o2 = %s\n", ((PedDisk *)o->obj)->type->name,
>                 ((PedPartition *)o2->obj));
> 
> That results in: "o = msdos, o2 = ".  So I'm guessing the PedPartition is
> incorrect, or maybe my printf is just wrong.

Your printf looks wrong.  o2->obj is a PedPartition*, not a %s string.

You might find it helpful to gdb python like this:

        python
        >>> import your-test-program

        in another window:
        $ gdb python [PID of first python]
        (gdb) break [function on python-arted]
        (gdb) break ped_exception_throw
        (gdb) cont

        switch back to python:
        >>> run_test

        switch to gdb:
        (gdb) print * (PedPartition*) o2->obj

> I'm not familiar enough with the structures to really know the best
> parts to be printing.  Does it look like I'm on the right track here?

Well, it does look suspect that foo == 0, so you might be onto
something :)

Cheers,
Andrew





reply via email to

[Prev in Thread] Current Thread [Next in Thread]