Sorry, you're right, I didn't notice the x = plpy.SPIError() test.
I did notice that you included the kw != NULL, I was explaining why itreally is needed even though it *seems* the code also works withoutit.
There's just the doc part left then.