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.
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index c4f57e4..abdb939 100644
--- 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
index 109549e..78fa24b 100644
--- 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`.)
+
.. _other-improvements-3.4: