Commit 95c9e5f5 authored by Guido van Rossum's avatar Guido van Rossum

Get rid of the bogus short_repr(); a much nicer one is in the standard

repr module.
parent 40f1a033
...@@ -24,24 +24,5 @@ def new_label(): ...@@ -24,24 +24,5 @@ def new_label():
def log(message, level=zLOG.BLATHER, label=None, error=None): def log(message, level=zLOG.BLATHER, label=None, error=None):
zLOG.LOG(label or _label, level, message, error=error) zLOG.LOG(label or _label, level, message, error=error)
REPR_LIMIT = 40 # There's a nice "short_repr" function in the repr module:
from repr import repr as short_repr
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]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment