~ubuntu-branches/ubuntu/karmic/python3.0/karmic

« back to all changes in this revision

Viewing changes to Objects/rangeobject.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-16 17:18:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090216171823-1d5cm5qnnjvmnzzm
Tags: 3.0.1-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
    Algorithm is equal to that of get_len_of_range(), but it operates
124
124
    on PyObjects (which are assumed to be PyLong or PyInt objects).
125
125
    ---------------------------------------------------------------*/
126
 
    int cmp_result, cmp_call;
 
126
    int cmp_result;
127
127
    PyObject *lo, *hi;
128
128
    PyObject *step = NULL;
129
129
    PyObject *diff = NULL;
134
134
    PyObject *zero = PyLong_FromLong(0);
135
135
    if (zero == NULL)
136
136
        return NULL;
137
 
    cmp_call = PyObject_Cmp(r->step, zero, &cmp_result);
 
137
    cmp_result = PyObject_RichCompareBool(r->step, zero, Py_GT);
138
138
    Py_DECREF(zero);
139
 
    if (cmp_call == -1)
 
139
    if (cmp_result == -1)
140
140
        return NULL;
141
141
 
142
 
    assert(cmp_result != 0);
143
 
    if (cmp_result > 0) {
 
142
    if (cmp_result == 1) {
144
143
        lo = r->start;
145
144
        hi = r->stop;
146
145
        step = r->step;
154
153
    }
155
154
 
156
155
    /* if (lo >= hi), return length of 0. */
157
 
    if (PyObject_Compare(lo, hi) >= 0) {
 
156
    if (PyObject_RichCompareBool(lo, hi, Py_GE) == 1) {
158
157
        Py_XDECREF(step);
159
158
        return PyLong_FromLong(0);
160
159
    }
290
289
        0,                      /* tp_print */
291
290
        0,                      /* tp_getattr */
292
291
        0,                      /* tp_setattr */
293
 
        0,                      /* tp_compare */
 
292
        0,                      /* tp_reserved */
294
293
        (reprfunc)range_repr,   /* tp_repr */
295
294
        0,                      /* tp_as_number */
296
295
        &range_as_sequence,     /* tp_as_sequence */
386
385
        0,                                      /* tp_print */
387
386
        0,                                      /* tp_getattr */
388
387
        0,                                      /* tp_setattr */
389
 
        0,                                      /* tp_compare */
 
388
        0,                                      /* tp_reserved */
390
389
        0,                                      /* tp_repr */
391
390
        0,                                      /* tp_as_number */
392
391
        0,                                      /* tp_as_sequence */
538
537
        0,                                      /* tp_print */
539
538
        0,                                      /* tp_getattr */
540
539
        0,                                      /* tp_setattr */
541
 
        0,                                      /* tp_compare */
 
540
        0,                                      /* tp_reserved */
542
541
        0,                                      /* tp_repr */
543
542
        0,                                      /* tp_as_number */
544
543
        0,                                      /* tp_as_sequence */