Two possibilities come to mind, both of them have to do with the assumption of certain circuit elements.
First, the script assumes you have a net called clk. In the code, I do a find('/clk') without checking if anything is found. The subsequent call to .value() then causes a seg fault for me if clk isn't there.
Second, the script assume you have a module called U1. In this case, pcbnew doesn't seg fault, but rather gives a cryptic message.
I've added a check for both in the code. Hopefully, that will fix your crash.
To get the full benefit of the demo, you'll want to change clk and U1 to items you do have.
Sorry about that.