Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom serializer cannot return "None" #317

Open
rommeswi opened this issue May 15, 2024 · 0 comments
Open

Custom serializer cannot return "None" #317

rommeswi opened this issue May 15, 2024 · 0 comments

Comments

@rommeswi
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant