From: Zooko O'Whielacronx Date: Fri, 18 Apr 2008 04:32:38 +0000 (-0700) Subject: let MutableFileNode.__repr__() return something useful even if it isn't not initializ... X-Git-Tag: allmydata-tahoe-1.1.0~219 X-Git-Url: https://git.rkrishnan.org/class-simplejson.JSONDecoder-index.html?a=commitdiff_plain;h=a504f3395f8d4e42c8361b610aa68fc91c13a0fd;p=tahoe-lafs%2Ftahoe-lafs.git 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.) --- 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