[Python-checkins] bpo-38908: [docs] Add changes to 3.10 whatsnew and fix some minor inaccuracies in news (GH-26096)

miss-islington webhook-mailer at python.org
Mon May 24 19:51:16 EDT 2021


https://github.com/python/cpython/commit/8450e8a81f6d54f45e1fc5c13a03878c9978750d
commit: 8450e8a81f6d54f45e1fc5c13a03878c9978750d
branch: main
author: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-05-24T16:51:08-07:00
summary:

bpo-38908: [docs] Add changes to 3.10 whatsnew and fix some minor inaccuracies in news (GH-26096)



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.

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

diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 6443b78c8fa4c..a006eb4d6c534 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -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
 --------
 
diff --git a/Misc/NEWS.d/next/Library/2021-05-12-16-43-21.bpo-38908.nM2_rO.rst b/Misc/NEWS.d/next/Library/2021-05-12-16-43-21.bpo-38908.nM2_rO.rst
index b72936c205f67..18e3dd4066c4a 100644
--- a/Misc/NEWS.d/next/Library/2021-05-12-16-43-21.bpo-38908.nM2_rO.rst
+++ b/Misc/NEWS.d/next/Library/2021-05-12-16-43-21.bpo-38908.nM2_rO.rst
@@ -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.



More information about the Python-checkins mailing list