From a123df0aec63a644753faccdb71f59e51fc0eefa Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Sun, 17 Apr 2022 12:34:05 -0700 Subject: [PATCH 1/3] deprecate spwd --- Lib/test/test_spwd.py | 5 ++++- .../Library/2022-04-17-12-32-40.gh-issue-91217.ms49Rg.rst | 1 + Modules/spwdmodule.c | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-04-17-12-32-40.gh-issue-91217.ms49Rg.rst diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py index a143acc659ef6a..50766c25482a61 100644 --- a/Lib/test/test_spwd.py +++ b/Lib/test/test_spwd.py @@ -1,9 +1,12 @@ import os import unittest from test.support import import_helper +import warnings -spwd = import_helper.import_module('spwd') +with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + spwd = import_helper.import_module('spwd') @unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0, diff --git a/Misc/NEWS.d/next/Library/2022-04-17-12-32-40.gh-issue-91217.ms49Rg.rst b/Misc/NEWS.d/next/Library/2022-04-17-12-32-40.gh-issue-91217.ms49Rg.rst new file mode 100644 index 00000000000000..9655522d0eb46a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-17-12-32-40.gh-issue-91217.ms49Rg.rst @@ -0,0 +1 @@ +Deprecate the spwd module. diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c index acea30679bf5ec..0895b07fc62e81 100644 --- a/Modules/spwdmodule.c +++ b/Modules/spwdmodule.c @@ -256,5 +256,12 @@ static struct PyModuleDef spwdmodule = { PyMODINIT_FUNC PyInit_spwd(void) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "'nis' is deprecated and slated for removal in " + "Python 3.13", + 7)) { + return NULL; + } + return PyModuleDef_Init(&spwdmodule); } From 9cc85df4854dca408517c7f3b944eaa330885198 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 22 Apr 2022 17:12:47 -0700 Subject: [PATCH 2/3] Add to What's New --- Doc/whatsnew/3.11.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 653d32aaf540bf..24e112e60e0f9d 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -921,6 +921,7 @@ Deprecated * :mod:`ossaudiodev` * :mod:`pipes` * :mod:`sndhdr` + * :mod:`spwd` (Contributed by Brett Cannon in :issue:`47061`.) From 303896b410a5c326c04fc53264490b07534a0e54 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Sat, 23 Apr 2022 10:55:32 -0700 Subject: [PATCH 3/3] Update Modules/spwdmodule.c Co-authored-by: Hugo van Kemenade --- Modules/spwdmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c index 0895b07fc62e81..42123c93b59365 100644 --- a/Modules/spwdmodule.c +++ b/Modules/spwdmodule.c @@ -257,7 +257,7 @@ PyMODINIT_FUNC PyInit_spwd(void) { if (PyErr_WarnEx(PyExc_DeprecationWarning, - "'nis' is deprecated and slated for removal in " + "'spwd' is deprecated and slated for removal in " "Python 3.13", 7)) { return NULL;