From ea11920824bc3bad9014da2f7658b5c37cf14783 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 9 May 2024 12:39:21 +0300 Subject: [PATCH 1/4] gh-118827: Remove `Quoter` from `urllib.parse` --- Doc/whatsnew/3.14.rst | 3 +++ Lib/test/test_urlparse.py | 7 ------- Lib/urllib/parse.py | 8 -------- .../2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst | 2 ++ 4 files changed, 5 insertions(+), 15 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 24b6b617fe17dc..5b3bfcf277a709 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -122,6 +122,9 @@ Others These had previously raised a :exc:`DeprecationWarning` since Python 3.12. (Contributed by Raymond Hettinger in :gh:`101588`.) +* Remove deprecated ``Quoter`` class from :mod:`urllib.parse`. + It had previously raised a :exc:`DeprecationWarning` since Python 3.11. + Porting to Python 3.14 ====================== diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 236b6e4516490a..c12896a34fe13d 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -1426,13 +1426,6 @@ def test_unwrap(self): class DeprecationTest(unittest.TestCase): - - def test_Quoter_deprecation(self): - with self.assertWarns(DeprecationWarning) as cm: - old_class = urllib.parse.Quoter - self.assertIs(old_class, urllib.parse._Quoter) - self.assertIn('Quoter will be removed', str(cm.warning)) - def test_splittype_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: urllib.parse.splittype('') diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index fc9e7c99f283be..0fb7aefb34f02e 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -822,14 +822,6 @@ def unquote_plus(string, encoding='utf-8', errors='replace'): b'_.-~') _ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE) -def __getattr__(name): - if name == 'Quoter': - warnings.warn('Deprecated in 3.11. ' - 'urllib.parse.Quoter will be removed in Python 3.14. ' - 'It was not intended to be a public API.', - DeprecationWarning, stacklevel=2) - return _Quoter - raise AttributeError(f'module {__name__!r} has no attribute {name!r}') class _Quoter(dict): """A mapping from bytes numbers (in range(0,256)) to strings. diff --git a/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst b/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst new file mode 100644 index 00000000000000..836b47622feec1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst @@ -0,0 +1,2 @@ +Remove deprecated ``Quoter`` class from :mod:`urllib.parse`. It had +previously raised a :exc:`DeprecationWarning` since Python 3.11. From 3bd8a9a1f5bd373dcc9136e28c9dc211b74699d5 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 9 May 2024 14:56:12 +0300 Subject: [PATCH 2/4] Update 3.14.rst --- Doc/whatsnew/3.14.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 5b3bfcf277a709..08f63522331010 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -107,6 +107,12 @@ email * The *isdst* parameter has been removed from :func:`email.utils.localtime`. (Contributed by Hugo van Kemenade in :gh:`118798`.) +urllib +------ + +* Remove deprecated ``Quoter`` class from :mod:`urllib.parse`. + It had previously raised a :exc:`DeprecationWarning` since Python 3.11. + Others ------ @@ -122,9 +128,6 @@ Others These had previously raised a :exc:`DeprecationWarning` since Python 3.12. (Contributed by Raymond Hettinger in :gh:`101588`.) -* Remove deprecated ``Quoter`` class from :mod:`urllib.parse`. - It had previously raised a :exc:`DeprecationWarning` since Python 3.11. - Porting to Python 3.14 ====================== From 5175a9777a5e92c3984b1a6f904d3bd9b131513a Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 12 May 2024 13:53:52 +0300 Subject: [PATCH 3/4] Update 3.14.rst --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 8f998a1049b1b7..397812e7e34776 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -147,7 +147,7 @@ typing * Remove :class:`!typing.ByteString`. It had previously raised a :exc:`DeprecationWarning` since Python 3.12. - + urllib ------ From b6383f3179d6661c5ae8fc6586c263361aa02315 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 28 May 2024 11:46:37 +0300 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/whatsnew/3.14.rst | 3 ++- .../Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 397812e7e34776..a60e5abb9224fc 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -151,8 +151,9 @@ typing urllib ------ -* Remove deprecated ``Quoter`` class from :mod:`urllib.parse`. +* Remove deprecated :class:`!Quoter` class from :mod:`urllib.parse`. It had previously raised a :exc:`DeprecationWarning` since Python 3.11. + (Contributed by Nikita Sobolev in :gh:`118827`.) Others ------ diff --git a/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst b/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst index 836b47622feec1..40612dd93bd6da 100644 --- a/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst +++ b/Misc/NEWS.d/next/Library/2024-05-09-12-33-25.gh-issue-118827.JrzHz1.rst @@ -1,2 +1,3 @@ -Remove deprecated ``Quoter`` class from :mod:`urllib.parse`. It had +Remove deprecated :class:`!Quoter` class from :mod:`urllib.parse`. It had previously raised a :exc:`DeprecationWarning` since Python 3.11. +Patch by Nikita Sobolev.