~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Objects/structseq.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        PyStructSequence *obj;
33
33
 
34
34
        obj = PyObject_New(PyStructSequence, type);
 
35
        if (obj == NULL)
 
36
                return NULL;
35
37
        Py_SIZE(obj) = VISIBLE_SIZE_TP(type);
36
38
 
37
39
        return (PyObject*) obj;
522
524
        Py_INCREF(type);
523
525
 
524
526
        dict = type->tp_dict;
525
 
        PyDict_SetItemString(dict, visible_length_key, 
526
 
                       PyInt_FromLong((long) desc->n_in_sequence));
527
 
        PyDict_SetItemString(dict, real_length_key, 
528
 
                       PyInt_FromLong((long) n_members));
529
 
        PyDict_SetItemString(dict, unnamed_fields_key, 
530
 
                       PyInt_FromLong((long) n_unnamed_members));
 
527
#define SET_DICT_FROM_INT(key, value)                           \
 
528
        do {                                                    \
 
529
                PyObject *v = PyInt_FromLong((long) value);     \
 
530
                if (v != NULL) {                                \
 
531
                        PyDict_SetItemString(dict, key, v);     \
 
532
                        Py_DECREF(v);                           \
 
533
                }                                               \
 
534
        } while (0)
 
535
 
 
536
        SET_DICT_FROM_INT(visible_length_key, desc->n_in_sequence);
 
537
        SET_DICT_FROM_INT(real_length_key, n_members);
 
538
        SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members);
531
539
}