Commit f4289a81 authored by Douglas's avatar Douglas Committed by Ivan Tyagov

jupyter: erp5_kernel now correctly persists new-style classes without `_p_jar`

If ERP5 Jupyter kernel tried to persist an object created from a new-style class, it would crash because the object has no `_p_jar`. This makes the creation of the ObjectWriter fails. This kind of object needs to be handled by (c)Pickle.

Related to bug report https://nexedi.erp5.net/bug_module/20160819-882FA2, created by @kasra.

@Tyagov, please review when possible. 

/reviewed-on nexedi/erp5!162
parent dc2f3b39
Pipeline #2060 skipped
......@@ -449,7 +449,7 @@ def canSerialize(obj):
return all(result_list)
# if obj is an object and implements __getstate__, ZODB.serialize can check
# if we can store it
elif isinstance(obj, object) and hasattr(obj, '__getstate__'):
elif isinstance(obj, object) and hasattr(obj, '__getstate__') and hasattr(obj, '_p_jar'):
# Need to unwrap the variable, otherwise we get a TypeError, because
# objects cannot be pickled while inside an acquisition wrapper.
unwrapped_obj = Acquisition.aq_base(obj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment