From a504f3395f8d4e42c8361b610aa68fc91c13a0fd Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Thu, 17 Apr 2008 21:32:38 -0700 Subject: [PATCH] let MutableFileNode.__repr__() return something useful even if it isn't not initialize yet This is because I sometimes log or examine a repr of an object from a function which is being called from that object's own __init__()... (I'm committing this patch in order to test our patch management infrastructure.) --- src/allmydata/mutable/node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/allmydata/mutable/node.py b/src/allmydata/mutable/node.py index ae9a54a3..0267dcd7 100644 --- a/src/allmydata/mutable/node.py +++ b/src/allmydata/mutable/node.py @@ -70,7 +70,10 @@ class MutableFileNode: self._serializer = defer.succeed(None) def __repr__(self): - return "<%s %x %s %s>" % (self.__class__.__name__, id(self), self.is_readonly() and 'RO' or 'RW', hasattr(self, '_uri') and self._uri.abbrev()) + if hasattr(self, '_uri'): + return "<%s %x %s %s>" % (self.__class__.__name__, id(self), self.is_readonly() and 'RO' or 'RW', self._uri.abbrev()) + else: + return "<%s %x %s %s>" % (self.__class__.__name__, id(self), None, None) def init_from_uri(self, myuri): # we have the URI, but we have not yet retrieved the public -- 2.45.2