Handle unserializable warning arguments

Fix #349
This commit is contained in:
Bruno Oliveira
2018-10-29 18:47:43 -03:00
parent 70688b7986
commit b151e56fbd
4 changed files with 37 additions and 4 deletions

View File

@@ -426,9 +426,16 @@ def unserialize_warning_message(data):
if data["message_module"]:
mod = importlib.import_module(data["message_module"])
cls = getattr(mod, data["message_class_name"])
try:
message = cls(*data["message_args"])
except TypeError:
message = None
if data["message_args"] is not None:
try:
message = cls(*data["message_args"])
except TypeError:
pass
if message is None:
# could not recreate the original warning instance;
# create a generic Warning instance with the original
# message at least
message_text = "{mod}.{cls}: {msg}".format(
mod=data["message_module"],
cls=data["message_class_name"],