← Back to team overview

kicad-developers team mailing list archive

Re: PATCH: fix crash in netlist updater

 

I just tried your code on linux, python3 and I don't get any exceptions:

import pcbnew
b = pcbnew.GetBoard()
d = b.GetDrawings()
d
<pcbnew.DRAWINGS; proxy of <Swig Object of type 'std::deque< BOARD_ITEM * >
*' at 0x7fe9769e6d80> >
for a in d:
    print(a)

<pcbnew.TEXTE_PCB; proxy of <Swig Object of type 'TEXTE_PCB *' at
0x7fe9769e6de0> >
<pcbnew.TEXTE_PCB; proxy of <Swig Object of type 'TEXTE_PCB *' at
0x7fe9769e6e40> >
...

m = b.GetModules()
for mod in m:
    print(mod)

<pcbnew.MODULE; proxy of <Swig Object of type 'MODULE *' at 0x7fe9769e6d50>
>
<pcbnew.MODULE; proxy of <Swig Object of type 'MODULE *' at 0x7fe9769e6d20>
>
...

If you look at generated pcbnew.py (and make sure it's installed in
dist-packages) do you see new __iter__ method in DRAWINGS class?


On Tue, Jun 4, 2019 at 4:27 PM Seth Hillbrand <seth@xxxxxxxxxxxxx> wrote:

> On 2019-06-04 14:23, Andrew Lutsenko wrote:
> > Seth,
> >
> > 1. No, it's not needed. At first I didn't find Cast() in BOARD_ITEMS
> > cpp code so thought it's implemented in descendant classes only and
> > added the check as safeguard like it was done in DList. But now I
> > found that Cast() is in swig python extension for BOARD_ITEM so it
> > will always be defined. See amended patch attached.
> > 2. Yes, it works and it was tested on py3 build. Self reference is
> > passed implicitly in python.
>
> Hi Andrew-
>
> Thanks for the clear details.
>
> I tested this (Linux/python3) but I'm getting the StopIteration raised
> rather than handled by the standard python loops.  The example code I
> used was
>
> import pcbnew
> b = pcbnew.GetBoard()
> d = b.GetDrawings()
> for dwg in d:
>      print(dwg)
> m = b.GetModules()
> for mod in m:
>      print(mod)
>
> Here, the modules print normally and the StopIteration is handled
> internally by python.  The drawings pass the StopIteration back up to
> the UI.
>
> -Seth
>

Follow ups

References