-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
For some reason, marshmallow Schemas are not pickle-able if type is used to generate them:
Works just fine:
class Schema1(ma.Schema):
a = ma.fields.Str()
schema1 = Schema1()
pickle.dump(schema1, open("schema1.pickle", "wb"))Breaks:
Schema2 = type(
"Schema2",
(ma.Schema, ),
{"a": ma.fields.Str()}
)
schema2 = Schema2()
pickle.dump(schema2, open("schema2.pickle", "wb"))
# ---------------------------------------------------------------------------
# PicklingError Traceback (most recent call last)
# <ipython-input-3-3309ac14ecbf> in <module>
# 6
# 7 schema2 = Schema2()
# ----> 8 pickle.dump(schema2, open("schema2.pickle", "wb"))
# PicklingError: Can't pickle <class 'marshmallow.schema.Schema2'>: attribute lookup Schema2 on marshmallow.schema failedThanks for the bug report @jdebacker.
jdebacker
Metadata
Metadata
Assignees
Labels
No labels