One interesting bug that has cropped up occurs when I use the library to output some text and tspan elements. As an example I have included the original file, the output of svggrayscale.py, Inkscape's saved version of the output, and a fixed version of Inkscape's output. It seems to be adding extra text XML elements (tabs, newlines, spaces) when loaded in Inkscape, so the text displays with an offset to the right. At first I thought it was a problem with SVG-Utils, but librsvg 2.7.2 renders the output from svggrayscale correctly, so now I'm not sure. I hope you could look into this issue and help me to understand why it is happening.
Use Batik and/or Adobe SVG plugin as reference renderers. In this case they both display the same as Inkscape, so the problem is not with Inkscape.
Your script adds newlines between <text> and <tspan>. Within <text>, whitespace is meaningful and is displayed as text. Note that Inkscape, when creating <text>, does not leave any extra whitespace inside.