Hang on. On lines L255 and L256 you want the raw function definition, which means you must not encode it as a string, is that correct?

Regardless of the answer, the first part of my comment above remains true.