I don't think it is the Color object, In GEGL a "buffer" is a a pixel area that is exchanged between GEGL and its caller. Looking at the stack trace is comes from the add_alpha step, but given your code it could also be probably coming from the selection steps.
However, you have this strange pyi object. What is hiding behind it? Why pyi.drawable_edit_clear(layer) when you can do layer.edit_clear(). Why pyi.gimp_selection_invert(layer) instead of image.get_selection().invert(image)? (and remark that a selection is attached to an image and not to a layer). The code in that pyi thing would be my first place to search...
However, you have this strange pyi object. What is hiding behind it? Why pyi.drawable_edit_clear(layer) when you can do layer.edit_clear(). Why pyi.gimp_selection_invert(layer) instead of image.get_selection().invert(image)? (and remark that a selection is attached to an image and not to a layer). The code in that pyi thing would be my first place to search...