[kupfer: 29/31] puid: If a Serilizable object can't be pickled, return None



commit 5822d5ba14d538b45adcccef4716ae846eba9ca3
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Dec 31 13:27:17 2009 +0100

    puid: If a Serilizable object can't be pickled, return None

 kupfer/puid.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/puid.py b/kupfer/puid.py
index d29e6ce..d1ccc87 100644
--- a/kupfer/puid.py
+++ b/kupfer/puid.py
@@ -31,7 +31,11 @@ def get_unique_id(obj):
 	if hasattr(obj, "qf_id"):
 		return str(qfurl.qfurl(obj))
 	if hasattr(obj, SERIALIZABLE_ATTRIBUTE):
-		return SerializedObject(obj)
+		try:
+			return SerializedObject(obj)
+		except pickle.PicklingError, exc:
+			pretty.print_error(__name__, type(exc).__name__, exc)
+			return None
 	return repr(obj)
 
 def is_reference(puid):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]