]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38908: [docs] Add changes to 3.10 whatsnew and fix some minor inaccuracies in...
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Mon, 24 May 2021 23:51:08 +0000 (07:51 +0800)
committerGitHub <noreply@github.com>
Mon, 24 May 2021 23:51:08 +0000 (16:51 -0700)
The fix only applies to ``isinstance``. ``issubclass`` isn't affected (because it was always working to begin with). So I also fixed the news to reflect that.

Doc/whatsnew/3.10.rst
Misc/NEWS.d/next/Library/2021-05-12-16-43-21.bpo-38908.nM2_rO.rst

index 6443b78c8fa4cb74afd295117da1efd7600dbea4..a006eb4d6c534f49a3e91778ea6c9192036e2f4e 100644 (file)
@@ -1317,6 +1317,14 @@ Add new function :func:`typing.is_typeddict` to introspect if an annotation
 is a :class:`typing.TypedDict`.
 (Contributed by Patrick Reader in :issue:`41792`)
 
+Subclasses of ``typing.Protocol`` which only have data variables declared
+will now raise a ``TypeError`` when checked with ``isinstance`` unless they
+are decorated with :func:`runtime_checkable`.  Previously, these checks
+passed silently.  Users should decorate their
+subclasses with the :func:`runtime_checkable` decorator
+if they want runtime protocols.
+(Contributed by Yurii Karabas in :issue:`38908`)
+
 unittest
 --------
 
index b72936c205f67c26c07553ed7f344ad0ed09758e..18e3dd4066c4af40c72b46632c8cca2bba6b68d6 100644 (file)
@@ -1,5 +1,5 @@
-Fix issue where :mod:`typing` protocols without the  ``@runtime_checkable``
-decorator did not raise a ``TypeError`` when used with ``issubclass`` and
-``isinstance``.  Now, subclassses of ``typing.Protocol`` will raise a
-``TypeError`` when used with with those checks.
+Subclasses of ``typing.Protocol`` which only have data variables declared
+will now raise a ``TypeError`` when checked with ``isinstance`` unless they
+are decorated with :func:`runtime_checkable`.  Previously, these checks
+passed silently.
 Patch provided by Yurii Karabas.