~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_static_tuple_c.c

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-18 01:10:16 UTC
  • mfrom: (4763.2.3 st-size-exceptions)
  • Revision ID: pqm@pqm.ubuntu.com-20100218011016-cx9drbdydd2xmu2p
(mbp) clean up exceptions from StaticTuple_New

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
StaticTuple_New(Py_ssize_t size)
141
141
{
142
142
    StaticTuple *stuple;
143
 
    if (size < 0) {
144
 
        PyErr_BadInternalCall();
145
 
        return NULL;
146
 
    }
147
143
 
148
144
    if (size < 0 || size > 255) {
149
145
        /* Too big or too small */
280
276
        return NULL;
281
277
    }
282
278
    len = PyTuple_GET_SIZE(args);
 
279
    if (len < 0 || len > 255) {
 
280
        /* Check the length here so we can raise a TypeError instead of
 
281
         * StaticTuple_New's ValueError.
 
282
         */
 
283
        PyErr_SetString(PyExc_TypeError, "StaticTuple(...)"
 
284
            " takes from 0 to 255 items");
 
285
        return NULL;
 
286
    }
283
287
    self = (StaticTuple *)StaticTuple_New(len);
284
288
    if (self == NULL) {
285
289
        return NULL;