Custom serializer cannot return "None"
rommeswi opened this issue · comments
rommeswi commented
I tried to write a custom serializer that does not serialize functions. Assuming returning None would avoid serialization, I tried:
def custom_serializer(key, value):
if callable(value):
# If value is a function, return None to exclude it from serialization
return None
else:
# Serialize non-function values using the default pickle serializer
return pickle.dumps(value)
However, this does not work due to an sql error sqlite3.ProgrammingError: Error binding parameter 2: type 'function' is not supported
. The above serializeronly works only if the serializer returns not None.
I am not sure if this is an actual issue or whether I am using the wrong appoarch?