answered 9 years ago
Multiplication needs *, it works for me:
*
sage: (x^2*y+f.diff(x,1)).subs(f.diff(x,1)==g) x^2*y + g(x, y)