~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_static_tuple_c.c

  • Committer: Matt Nordhoff
  • Date: 2009-10-22 08:28:04 UTC
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5045.
  • Revision ID: mnordhoff@mattnordhoff.com-20091022082804-outyhrw2y14fxt4x
Make StaticTuple_New always raise a ValueError, and StaticTuple_new_constructor always raise a TypeError.

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 */
274
270
        return NULL;
275
271
    }
276
272
    len = PyTuple_GET_SIZE(args);
 
273
    if (len < 0 || len > 255) {
 
274
        /* Check the length here so we can raise a TypeError instead of
 
275
         * StaticTuple_New's ValueError.
 
276
         */
 
277
        PyErr_SetString(PyExc_TypeError, "StaticTuple(...)"
 
278
            " takes from 0 to 255 items");
 
279
        return NULL;
 
280
    }
277
281
    self = (StaticTuple *)StaticTuple_New(len);
278
282
    if (self == NULL) {
279
283
        return NULL;