[Zodb-checkins] CVS: ZODB3/ZEO/zrpc - log.py:1.4
Guido van Rossum
guido@python.org
Fri, 13 Sep 2002 16:53:21 -0400
Update of /cvs-repository/ZODB3/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv8114
Modified Files:
log.py
Log Message:
Get rid of the bogus short_repr(); a much nicer one is in the standard
repr module.
=== ZODB3/ZEO/zrpc/log.py 1.3 => 1.4 ===
--- ZODB3/ZEO/zrpc/log.py:1.3 Fri Aug 30 17:41:35 2002
+++ ZODB3/ZEO/zrpc/log.py Fri Sep 13 16:53:20 2002
@@ -24,24 +24,5 @@
def log(message, level=zLOG.BLATHER, label=None, error=None):
zLOG.LOG(label or _label, level, message, error=error)
-REPR_LIMIT = 40
-
-def short_repr(obj):
- "Return an object repr limited to REPR_LIMIT bytes."
- # Some of the objects being repr'd are large strings. It's wastes
- # a lot of memory to repr them and then truncate, so special case
- # them in this function.
- # Also handle short repr of a tuple containing a long string.
- if isinstance(obj, types.StringType):
- obj = obj[:REPR_LIMIT]
- elif isinstance(obj, types.TupleType):
- elts = []
- size = 0
- for elt in obj:
- r = repr(elt)
- elts.append(r)
- size += len(r)
- if size > REPR_LIMIT:
- break
- obj = tuple(elts)
- return repr(obj)[:REPR_LIMIT]
+# There's a nice "short_repr" function in the repr module:
+from repr import repr as short_repr