diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 5b53fbe0dda..34742515168 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -929,6 +929,7 @@ Deprecated * :mod:`ossaudiodev` * :mod:`pipes` * :mod:`sndhdr` + * :mod:`spwd` (Contributed by Brett Cannon in :issue:`47061`.) diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py index a143acc659e..50766c25482 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 00000000000..9655522d0eb --- /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 acea30679bf..42123c93b59 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, + "'spwd' is deprecated and slated for removal in " + "Python 3.13", + 7)) { + return NULL; + } + return PyModuleDef_Init(&spwdmodule); }