~pythonregexp2.7/python/issue2636-12

« back to all changes in this revision

Viewing changes to Objects/typeobject.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:52:42 UTC
  • mfrom: (39033.1.3 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609145242-9m268zc6u87rp1vp
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP];
34
34
static unsigned int next_version_tag = 0;
35
 
static void type_modified(PyTypeObject *);
36
35
 
37
36
unsigned int
38
37
PyType_ClearCache(void)
47
46
        }
48
47
        next_version_tag = 0;
49
48
        /* mark all version tags as invalid */
50
 
        type_modified(&PyBaseObject_Type);
 
49
        PyType_Modified(&PyBaseObject_Type);
51
50
        return cur_version_tag;
52
51
}
53
52
 
54
 
static void
55
 
type_modified(PyTypeObject *type)
 
53
void
 
54
PyType_Modified(PyTypeObject *type)
56
55
{
57
56
        /* Invalidate any cached data for the specified type and all
58
57
           subclasses.  This function is called after the base
86
85
                        ref = PyList_GET_ITEM(raw, i);
87
86
                        ref = PyWeakref_GET_OBJECT(ref);
88
87
                        if (ref != Py_None) {
89
 
                                type_modified((PyTypeObject *)ref);
 
88
                                PyType_Modified((PyTypeObject *)ref);
90
89
                        }
91
90
                }
92
91
        }
172
171
                        Py_INCREF(Py_None);
173
172
                }
174
173
                /* mark all version tags as invalid */
175
 
                type_modified(&PyBaseObject_Type);
 
174
                PyType_Modified(&PyBaseObject_Type);
176
175
                return 1;
177
176
        }
178
177
        bases = type->tp_bases;
300
299
                return -1;
301
300
        }
302
301
 
303
 
        type_modified(type);
 
302
        PyType_Modified(type);
304
303
 
305
304
        return PyDict_SetItemString(type->tp_dict, "__module__", value);
306
305
}
328
327
        int res = PyDict_SetItemString(type->tp_dict,
329
328
                                       "__abstractmethods__", value);
330
329
        if (res == 0) {
331
 
                type_modified(type);
 
330
                PyType_Modified(type);
332
331
                if (value && PyObject_IsTrue(value)) {
333
332
                        type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT;
334
333
                }
1621
1620
           from the custom MRO */
1622
1621
        type_mro_modified(type, type->tp_bases);
1623
1622
 
1624
 
        type_modified(type);
 
1623
        PyType_Modified(type);
1625
1624
 
1626
1625
        return 0;
1627
1626
}
3398
3397
        return result;
3399
3398
}
3400
3399
 
 
3400
static PyObject *
 
3401
object_sizeof(PyObject *self, PyObject *args)
 
3402
{
 
3403
        Py_ssize_t res, isize;
 
3404
 
 
3405
        res = 0;
 
3406
        isize = self->ob_type->tp_itemsize;
 
3407
        if (isize > 0)
 
3408
                res = self->ob_type->ob_size * isize;
 
3409
        res += self->ob_type->tp_basicsize;
 
3410
 
 
3411
        return PyInt_FromSsize_t(res);   
 
3412
}
 
3413
 
3401
3414
static PyMethodDef object_methods[] = {
3402
3415
        {"__reduce_ex__", object_reduce_ex, METH_VARARGS,
3403
3416
         PyDoc_STR("helper for pickle")},
3407
3420
         object_subclasshook_doc},
3408
3421
        {"__format__", object_format, METH_VARARGS,
3409
3422
         PyDoc_STR("default object formatter")},
 
3423
        {"__sizeof__", object_sizeof, METH_NOARGS,
 
3424
         PyDoc_STR("__sizeof__() -> size of object in memory, in bytes")},
3410
3425
        {0}
3411
3426
};
3412
3427
 
6092
6107
           update_subclasses() recursion below, but carefully:
6093
6108
           they each have their own conditions on which to stop
6094
6109
           recursing into subclasses. */
6095
 
        type_modified(type);
 
6110
        PyType_Modified(type);
6096
6111
 
6097
6112
        init_slotdefs();
6098
6113
        pp = ptrs;