mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 16:26:30 +01:00
Fix serialization for Class store, add more log error on dbserialize error. Resolve #1979
This commit is contained in:
parent
92fb7fa0f2
commit
85535b7baa
1 changed files with 17 additions and 3 deletions
|
|
@ -572,7 +572,13 @@ def to_pickle(data):
|
|||
return [process_item(val) for val in item]
|
||||
elif hasattr(item, "sessid") and hasattr(item, "conn_time"):
|
||||
return pack_session(item)
|
||||
return pack_dbobj(item)
|
||||
try:
|
||||
return pack_dbobj(item)
|
||||
except TypeError:
|
||||
return item
|
||||
except Exception:
|
||||
logger.log_error(f"The object {item} of type {type(item)} could not be stored.")
|
||||
raise
|
||||
|
||||
return process_item(data)
|
||||
|
||||
|
|
@ -707,12 +713,20 @@ def from_pickle(data, db_obj=None):
|
|||
|
||||
def do_pickle(data):
|
||||
"""Perform pickle to string"""
|
||||
return dumps(data, protocol=PICKLE_PROTOCOL)
|
||||
try:
|
||||
return dumps(data, protocol=PICKLE_PROTOCOL)
|
||||
except Exception:
|
||||
logger.log_error(f"Could not pickle data for storage: {data}")
|
||||
raise
|
||||
|
||||
|
||||
def do_unpickle(data):
|
||||
"""Retrieve pickle from pickled string"""
|
||||
return loads(to_bytes(data))
|
||||
try:
|
||||
return loads(to_bytes(data))
|
||||
except Exception:
|
||||
logger.log_error(f"Could not unpickle data from storage: {data}")
|
||||
raise
|
||||
|
||||
|
||||
def dbserialize(data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue