Skip to content

Commit

Permalink
gh-91217: deprecate spwd (#91846)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
  • Loading branch information
brettcannon and hugovk committed Apr 23, 2022
1 parent 2889042 commit 692e907
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ Deprecated
* :mod:`ossaudiodev`
* :mod:`pipes`
* :mod:`sndhdr`
* :mod:`spwd`

(Contributed by Brett Cannon in :issue:`47061`.)

Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_spwd.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate the spwd module.
7 changes: 7 additions & 0 deletions Modules/spwdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 692e907

Please sign in to comment.