Commit c48e4008 authored by Tres Seaver's avatar Tres Seaver

Fit the 'repr' of bucket objects.

Broeken version could contain garbage characters.
parent 7d84f2f2
...@@ -1840,9 +1840,9 @@ bucket_repr(Bucket *self) ...@@ -1840,9 +1840,9 @@ bucket_repr(Bucket *self)
{ {
Py_DECREF(r); Py_DECREF(r);
#ifdef PY3K #ifdef PY3K
return PyUnicode_DecodeLatin1(repr, sizeof(repr), "surrogateescape"); return PyUnicode_DecodeLatin1(repr, strlen(repr), "surrogateescape");
#else #else
return PyBytes_FromStringAndSize(repr, sizeof(repr)); return PyBytes_FromStringAndSize(repr, strlen(repr));
#endif #endif
} }
else else
......
...@@ -202,6 +202,18 @@ class MappingBase(Base): ...@@ -202,6 +202,18 @@ class MappingBase(Base):
for i in range(l): for i in range(l):
t[i]=i t[i]=i
def testShortRepr(self):
# test the repr because buckets have a complex repr implementation
# internally the cutoff from a stack allocated buffer to a heap
# allocated buffer is 10000.
t = self._makeOne()
for i in range(5):
t[i] = i
r = repr(t)
# Make sure the repr is **not* 10000 bytes long for a shrort bucket.
# (the buffer must be terminated when copied).
self.assertTrue(len(r) < 10000)
def testRepr(self): def testRepr(self):
# test the repr because buckets have a complex repr implementation # test the repr because buckets have a complex repr implementation
# internally the cutoff from a stack allocated buffer to a heap # internally the cutoff from a stack allocated buffer to a heap
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
4.0.5 (unreleased) 4.0.5 (unreleased)
------------------ ------------------
- TBD - Fit the ``repr`` of bucket objects, which could contain garbage
characters.
4.0.4 (2013-01-12) 4.0.4 (2013-01-12)
......
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