[kupfer: 29/31] puid: If a Serilizable object can't be pickled, return None
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 29/31] puid: If a Serilizable object can't be pickled, return None
- Date: Thu, 31 Dec 2009 12:56:53 +0000 (UTC)
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]