diff -r aa0e6eab6136 Doc/library/types.rst --- a/Doc/library/types.rst Sat Aug 25 21:33:56 2012 +0200 +++ b/Doc/library/types.rst Sat Aug 25 21:00:34 2012 -0700 @@ -74,27 +74,42 @@ Standard names are defined for the following types: -.. data:: FunctionType - LambdaType +.. class:: FunctionType(code, globals) +.. class:: LambdaType(code, globals) + + LambaType is a synonym for FunctionType() + + Create a function object from a code object and a dictionary. + The optional name string overrides the name from the code object. + The optional argdefs tuple specifiees the default argument values. + The optional closure tuple supplies the bindings for free variables. + The type of user-defined functions and functions created by :keyword:`lambda` expressions. + .. data:: GeneratorType + This does support direct creation. + Please see :class:`GeneratorType` (imp.new_module) The type of :term:`generator`-iterator objects, produced by calling a generator function. -.. data:: CodeType +.. class:: CodeType(argcount, kwonlyargcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) + + Create a code object. Not for the faint of heart. .. index:: builtin: compile The type for code objects such as returned by :func:`compile`. -.. data:: MethodType +.. class:: MethodType(function, instance) + + Create a bound instance method object. The type of methods of user-defined class instances. @@ -102,6 +117,8 @@ .. data:: BuiltinFunctionType BuiltinMethodType + This does support direct creation. + Please see :class:`ModuleType` (imp.new_module). The type of built-in functions like :func:`len` or :func:`sys.exit`, and methods of built-in classes. (Here, the term "built-in" means "written in C".) @@ -114,17 +131,26 @@ .. data:: TracebackType + + This does support direct creation. + Please see :class:`ModuleType` (imp.new_module). The type of traceback objects such as found in ``sys.exc_info()[2]``. .. data:: FrameType + This does support direct creation. + Please see :class:`FrameType` (imp.new_module) + The type of frame objects such as found in ``tb.tb_frame`` if ``tb`` is a traceback object. .. data:: GetSetDescriptorType + + This does support direct creation. + Please see :class:`GetSetDescriptorType` (imp.new_module). The type of objects defined in extension modules with ``PyGetSetDef``, such as ``FrameType.f_locals`` or ``array.array.typecode``. This type is used as descriptor for object attributes; it has the same purpose as the @@ -133,6 +159,8 @@ .. data:: MemberDescriptorType + This does support direct creation. + Please see :class:`MemberDescriptorType` (imp.new_module). The type of objects defined in extension modules with ``PyMemberDef``, such as ``datetime.timedelta.days``. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose @@ -146,8 +174,8 @@ .. class:: MappingProxyType(mapping) Read-only proxy of a mapping. It provides a dynamic view on the mapping's - entries, which means that when the mapping changes, the view reflects these - changes. + entries, which means that when the mapping changes, the view reflects + these changes. .. versionadded:: 3.3 @@ -196,6 +224,10 @@ .. class:: SimpleNamespace + A simple attribute-based namespace. + + namespace(**kwargs) + A simple :class:`object` subclass that provides attribute access to its namespace, as well as a meaningful repr. diff -r aa0e6eab6136 Objects/descrobject.c --- a/Objects/descrobject.c Sat Aug 25 21:33:56 2012 +0200 +++ b/Objects/descrobject.c Sat Aug 25 21:00:34 2012 -0700 @@ -919,7 +919,9 @@ _PyObject_GC_TRACK(mappingproxy); return (PyObject *)mappingproxy; } - +PyDoc_STRVAR(mappingproxy_doc,"It's a simple API that accepts a single\n" + "parameter (which must be a mapping) and returns a read-only\n" + "view of the original mapping."); PyTypeObject PyDictProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "mappingproxy", /* tp_name */ @@ -942,7 +944,7 @@ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ + mappingproxy_doc, /* tp_doc */ mappingproxy_traverse, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)mappingproxy_richcompare, /* tp_richcompare */ @@ -960,6 +962,7 @@ 0, /* tp_init */ 0, /* tp_alloc */ mappingproxy_new, /* tp_new */ + }; PyObject *