cpython: 8f403199f999 (original) (raw)

Mercurial > cpython

changeset 70331:8f403199f999

move specialized dir implementations into __dir__ methods (closes #12166) [#12166]

Benjamin Peterson benjamin@python.org
date Tue, 24 May 2011 11:09:06 -0500
parents 28c1f8480090
children 0e56d79fa2ab
files Lib/test/test_descrtut.py Misc/NEWS Objects/moduleobject.c Objects/object.c Objects/typeobject.c
diffstat 5 files changed, 178 insertions(+), 178 deletions(-)[+] [-] Lib/test/test_descrtut.py 1 Misc/NEWS 3 Objects/moduleobject.c 30 Objects/object.c 195 Objects/typeobject.c 127

line wrap: on

line diff

--- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -170,6 +170,7 @@ You can get the information from the lis 'contains', 'delattr', 'delitem',

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? Core and Builtins ----------------- +- Issue #12166: Move implementations of dir() specialized for various types into

--- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -413,6 +413,34 @@ module_clear(PyModuleObject *m) return 0; } +static PyObject * +module_dir(PyObject *self, PyObject *args) +{

+

+

+} + +static PyMethodDef module_methods[] = {

+}; + PyDoc_STRVAR(module_doc, "module(name[, doc])\n[](#l3.37) @@ -449,7 +477,7 @@ PyTypeObject PyModule_Type = { 0, /* tp_weaklistoffset / 0, / tp_iter / 0, / tp_iternext */

--- a/Objects/object.c +++ b/Objects/object.c @@ -1182,66 +1182,6 @@ PyCallable_Check(PyObject x) return x->ob_type->tp_call != NULL; } -/ ------------------------- PyObject_Dir() helpers ------------------------- / - -/ Helper for PyObject_Dir.

-static int -merge_class_dict(PyObject* dict, PyObject* aclass) -{

-

-

-

-} /* Helper for PyObject_Dir without arguments: returns the local scope. */ static PyObject * @@ -1269,133 +1209,34 @@ static PyObject return names; } -/ Helper for PyObject_Dir of type objects: returns dict and bases.

-

-

-} - -/* Helper for PyObject_Dir of module objects: returns the module's dict. */ -static PyObject * -_specialized_dir_module(PyObject *obj) -{

-

-

-} - -/* Helper for PyObject_Dir of generic objects: returns dict, class,

-

-

-

-

-error:

-} - -/* Helper for PyObject_Dir: object introspection.

--- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2572,6 +2572,82 @@ type_prepare(PyObject *self, PyObject a return PyDict_New(); } +/

+static int +merge_class_dict(PyObject *dict, PyObject *aclass) +{

+

+

+

+} + +/* dir for type objects: returns dict and bases.

+

+

+} + static PyMethodDef type_methods[] = { {"mro", (PyCFunction)mro_external, METH_NOARGS, PyDoc_STR("mro() -> list\nreturn a type's method resolution order")}, @@ -2585,6 +2661,8 @@ static PyMethodDef type_methods[] = { PyDoc_STR("instancecheck() -> check if an object is an instance")}, {"subclasscheck", type___subclasscheck__, METH_O, PyDoc_STR("subclasscheck() -> check if a class is a subclass")},

+

+

+

+

+error:

+} + static PyMethodDef object_methods[] = { {"reduce_ex", object_reduce_ex, METH_VARARGS, PyDoc_STR("helper for pickle")}, @@ -3449,6 +3574,8 @@ static PyMethodDef object_methods[] = { PyDoc_STR("default object formatter")}, {"sizeof", object_sizeof, METH_NOARGS, PyDoc_STR("sizeof() -> size of object in memory, in bytes")},