[Python-Dev] [Python-checkins] cpython: whatsnew: DynanicClassAttribute (#19030), Py_SetStandardStreamEncoding (#16129)

Nick Coghlan ncoghlan at gmail.com
Tue Feb 25 22:58:06 CET 2014


On 26 Feb 2014 07:04, "r.david.murray" <python-checkins at python.org> wrote:
>
> http://hg.python.org/cpython/rev/4cd620d8c3f6
> changeset:   89392:4cd620d8c3f6
> user:        R David Murray <rdmurray at bitdance.com>
> date:        Tue Feb 25 16:03:14 2014 -0500
> summary:
>   whatsnew: DynanicClassAttribute (#19030), Py_SetStandardStreamEncoding
(#16129)
>
> Adding missing docs for DynamicClassAttribute by copying the docstring.
 The
> doc entry could stand some expansion, which I will note on the issue.
>
> files:
>   Doc/library/types.rst |  21 +++++++++++++++++++++
>   Doc/whatsnew/3.4.rst  |  17 +++++++++++++++++
>   2 files changed, 38 insertions(+), 0 deletions(-)
>
>
> diff --git a/Doc/library/types.rst b/Doc/library/types.rst
> --- a/Doc/library/types.rst
> +++ b/Doc/library/types.rst
> @@ -15,6 +15,9 @@
>  Python interpreter, but not exposed as builtins like :class:`int` or
>  :class:`str` are.
>
> +Finally, it provides some additional type-related utility classes and
functions
> +that are not fundamental enough to be builtins.
> +
>
>  Dynamic Type Creation
>  ---------------------
> @@ -220,6 +223,9 @@
>        Return a new view of the underlying mapping's values.
>
>
> +Additional Utility Classes and Functions
> +----------------------------------------
> +
>  .. class:: SimpleNamespace
>
>     A simple :class:`object` subclass that provides attribute access to
its
> @@ -246,3 +252,18 @@
>     instead.
>
>     .. versionadded:: 3.3
> +
> +
> +.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None,
doc=None)
> +
> +   Route attribute access on a class to __getattr__.
> +
> +   This is a descriptor, used to define attributes that act differently
when
> +   accessed through an instance and through a class.  Instance access
remains
> +   normal, but access to an attribute through a class will be routed to
the
> +   class's __getattr__ method; this is done by raising AttributeError.
> +
> +   This allows one to have properties active on an instance, and have
virtual
> +   attributes on the class with the same name (see Enum for an example).
> +
> +   .. versionadded:: 3.4
> diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
> --- a/Doc/whatsnew/3.4.rst
> +++ b/Doc/whatsnew/3.4.rst
> @@ -1270,6 +1270,17 @@
>  :issue:`1565525`).
>
>
> +types
> +-----
> +
> +A new :func:`~types.DynamicClassAttribute` descriptor provides a way to
define
> +an attribute that acts normally when looked up through an instance
object, but
> +which is routed to the *class* ``__getattr__`` when looked up through the
> +class.  This allows one to have properties active on a class, and have
virtual
> +attributes on the class with the same name (see :mod:`Enum` for an
example).
> +(Contributed by Ethan Furman in :issue:`19030`.)
> +
> +
>  urllib
>  ------
>
> @@ -1512,6 +1523,12 @@
>    object allocator have been silenced.  (Contributed by Dhiru Kholia in
>    :issue:`18596`.)
>
> +* New function :c:func:`Py_SetStandardStreamEncoding` allows an
application
> +  that is embedding Python to do the equivalent of setting
> +  :envvar:`PYTHONIOENCODING`.  Its arguments override the equivalent
> +  values from :envvar:`PYTHONIOENCODING` if it exists.  (Contributed
> +  by Bastien Montagne and Nick Coghlan in :issue:`16129`.)
> +

There was an existing entry for this one: second bullet under
http://docs.python.org/dev/whatsnew/3.4.html#other-build-and-c-api-changes

Cheers,
Nick.

>
>  .. _other-improvements-3.4:
>
>
> --
> Repository URL: http://hg.python.org/cpython
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> https://mail.python.org/mailman/listinfo/python-checkins
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140226/64f53a56/attachment.html>


More information about the Python-Dev mailing list