# HG changeset patch # Parent c9d89d3f3ff17d547e541514ae91920cbabbfa7a diff -r c9d89d3f3ff1 Doc/c-api/module.rst --- a/Doc/c-api/module.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/c-api/module.rst Fri May 29 04:11:38 2015 +0000 @@ -59,10 +59,10 @@ .. index:: single: __dict__ (module attribute) Return the dictionary object that implements *module*'s namespace; this object - is the same as the :attr:`__dict__` attribute of the module object. This + is the same as the :attr:`~object.__dict__` attribute of the module object. This function never fails. It is recommended extensions use other :c:func:`PyModule_\*` and :c:func:`PyObject_\*` functions rather than directly - manipulate a module's :attr:`__dict__`. + manipulate a module's :attr:`~object.__dict__`. .. c:function:: PyObject* PyModule_GetNameObject(PyObject *module) diff -r c9d89d3f3ff1 Doc/c-api/typeobj.rst --- a/Doc/c-api/typeobj.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/c-api/typeobj.rst Fri May 29 04:11:38 2015 +0000 @@ -111,10 +111,10 @@ For statically allocated type objects, the tp_name field should contain a dot. Everything before the last dot is made accessible as the :attr:`__module__` attribute, and everything after the last dot is made accessible as the - :attr:`__name__` attribute. + :attr:`~definition.__name__` attribute. If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the - :attr:`__name__` attribute, and the :attr:`__module__` attribute is undefined + :attr:`~definition.__name__` attribute, and the :attr:`__module__` attribute is undefined (unless explicitly set in the dictionary, as explained above). This means your type will be impossible to pickle. diff -r c9d89d3f3ff1 Doc/library/builtins.rst --- a/Doc/library/builtins.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/library/builtins.rst Fri May 29 04:11:38 2015 +0000 @@ -36,6 +36,6 @@ As an implementation detail, most modules have the name ``__builtins__`` made available as part of their globals. The value of ``__builtins__`` is normally -either this module or the value of this module's :attr:`__dict__` attribute. +either this module or the value of this module's :attr:`~object.__dict__` attribute. Since this is an implementation detail, it may not be used by alternate implementations of Python. diff -r c9d89d3f3ff1 Doc/library/enum.rst --- a/Doc/library/enum.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/library/enum.rst Fri May 29 04:11:38 2015 +0000 @@ -431,7 +431,7 @@ the source, pickling will be disabled. The new pickle protocol 4 also, in some circumstances, relies on -:attr:`__qualname__` being set to the location where pickle will be able +:attr:`~definition.__qualname__` being set to the location where pickle will be able to find the class. For example, if the class was made available in class SomeData in the global scope:: diff -r c9d89d3f3ff1 Doc/library/functions.rst --- a/Doc/library/functions.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/library/functions.rst Fri May 29 04:11:38 2015 +0000 @@ -300,7 +300,7 @@ :func:`dir` reports their attributes. If the object does not provide :meth:`__dir__`, the function tries its best to - gather information from the object's :attr:`__dict__` attribute, if defined, and + gather information from the object's :attr:`~object.__dict__` attribute, if defined, and from its type object. The resulting list is not necessarily complete, and may be inaccurate when the object has a custom :func:`__getattr__`. @@ -1441,7 +1441,7 @@ With three arguments, return a new type object. This is essentially a dynamic form of the :keyword:`class` statement. The *name* string is the - class name and becomes the :attr:`~class.__name__` attribute; the *bases* + class name and becomes the :attr:`~definition.__name__` attribute; the *bases* tuple itemizes the base classes and becomes the :attr:`~class.__bases__` attribute; and the *dict* dictionary is the namespace containing definitions for class body and becomes the :attr:`~object.__dict__` attribute. For @@ -1458,11 +1458,11 @@ .. function:: vars([object]) Return the :attr:`~object.__dict__` attribute for a module, class, instance, - or any other object with a :attr:`__dict__` attribute. + or any other object with a :attr:`~object.__dict__` attribute. - Objects such as modules and instances have an updateable :attr:`__dict__` + Objects such as modules and instances have an updateable :attr:`~object.__dict__` attribute; however, other objects may have write restrictions on their - :attr:`__dict__` attributes (for example, classes use a + :attr:`~object.__dict__` attributes (for example, classes use a dictproxy to prevent direct dictionary updates). Without an argument, :func:`vars` acts like :func:`locals`. Note, the diff -r c9d89d3f3ff1 Doc/library/functools.rst --- a/Doc/library/functools.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/library/functools.rst Fri May 29 04:11:38 2015 +0000 @@ -473,7 +473,7 @@ :class:`partial` objects are like :class:`function` objects in that they are callable, weak referencable, and can have attributes. There are some important -differences. For instance, the :attr:`__name__` and :attr:`__doc__` attributes +differences. For instance, the :attr:`~definition.__name__` and :attr:`__doc__` attributes are not created automatically. Also, :class:`partial` objects defined in classes behave like static methods and do not transform into bound methods during instance attribute look-up. diff -r c9d89d3f3ff1 Doc/library/inspect.rst --- a/Doc/library/inspect.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/library/inspect.rst Fri May 29 04:11:38 2015 +0000 @@ -342,8 +342,9 @@ are true. This, for example, is true of ``int.__add__``. An object passing this test - has a :attr:`__get__` attribute but not a :attr:`__set__` attribute, but - beyond that the set of attributes varies. :attr:`__name__` is usually + has a :meth:`~object.__get__` method but not a :meth:`~object.__set__` + method, but beyond that the set of attributes varies. A + :attr:`~definition.__name__` attribute is usually sensible, and :attr:`__doc__` often is. Methods implemented via descriptors that also pass one of the other tests @@ -356,11 +357,11 @@ Return true if the object is a data descriptor. - Data descriptors have both a :attr:`__get__` and a :attr:`__set__` attribute. + Data descriptors have both a :attr:`~object.__get__` and a :attr:`~object.__set__` method. Examples are properties (defined in Python), getsets, and members. The latter two are defined in C and there are more specific tests available for those types, which is robust across Python implementations. Typically, data - descriptors will also have :attr:`__name__` and :attr:`__doc__` attributes + descriptors will also have :attr:`~definition.__name__` and :attr:`__doc__` attributes (properties, getsets, and members have both of these attributes), but this is not guaranteed. diff -r c9d89d3f3ff1 Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/library/stdtypes.rst Fri May 29 04:11:38 2015 +0000 @@ -4337,9 +4337,10 @@ A special attribute of every module is :attr:`~object.__dict__`. This is the dictionary containing the module's symbol table. Modifying this dictionary will actually change the module's symbol table, but direct assignment to the -:attr:`__dict__` attribute is not possible (you can write +:attr:`~object.__dict__` attribute is not possible (you can write ``m.__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but you can't write -``m.__dict__ = {}``). Modifying :attr:`__dict__` directly is not recommended. +``m.__dict__ = {}``). Modifying :attr:`~object.__dict__` directly is +not recommended. Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ``>> class C(object): @@ -383,7 +383,7 @@ AttributeError: 'C' object has no attribute 'newattr' Note how you get an :exc:`AttributeError` on the attempt to assign to an -attribute not listed in :attr:`__slots__`. +attribute not listed in :attr:`~object.__slots__`. .. _sect-rellinks: diff -r c9d89d3f3ff1 Doc/whatsnew/2.3.rst --- a/Doc/whatsnew/2.3.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/whatsnew/2.3.rst Fri May 29 04:11:38 2015 +0000 @@ -1111,10 +1111,10 @@ * One of the noted incompatibilities between old- and new-style classes has been - removed: you can now assign to the :attr:`__name__` and :attr:`__bases__` + removed: you can now assign to the :attr:`~definition.__name__` and :attr:`~class.__bases__` attributes of new-style classes. There are some restrictions on what can be - assigned to :attr:`__bases__` along the lines of those relating to assigning to - an instance's :attr:`__class__` attribute. + assigned to :attr:`~class.__bases__` along the lines of those relating to assigning to + an instance's :attr:`~instance.__class__` attribute. .. ====================================================================== @@ -1920,7 +1920,7 @@ * If you dynamically allocate type objects in your extension, you should be aware of a change in the rules relating to the :attr:`__module__` and - :attr:`__name__` attributes. In summary, you will want to ensure the type's + :attr:`~definition.__name__` attributes. In summary, you will want to ensure the type's dictionary contains a ``'__module__'`` key; making the module name the part of the type name leading up to the final period will no longer have the desired effect. For more detail, read the API reference documentation or the source. diff -r c9d89d3f3ff1 Doc/whatsnew/3.0.rst --- a/Doc/whatsnew/3.0.rst Thu May 28 17:30:03 2015 -0500 +++ b/Doc/whatsnew/3.0.rst Fri May 29 04:11:38 2015 +0000 @@ -783,8 +783,8 @@ :attr:`func_closure`, :attr:`func_code`, :attr:`func_defaults`, :attr:`func_dict`, :attr:`func_doc`, :attr:`func_globals`, :attr:`func_name` were renamed to :attr:`__closure__`, - :attr:`__code__`, :attr:`__defaults__`, :attr:`__dict__`, - :attr:`__doc__`, :attr:`__globals__`, :attr:`__name__`, + :attr:`__code__`, :attr:`__defaults__`, :attr:`~object.__dict__`, + :attr:`__doc__`, :attr:`__globals__`, :attr:`~definition.__name__`, respectively. * :meth:`__nonzero__` is now :meth:`__bool__`.