Skip to content

Commit 692e907

Browse files
brettcannonhugovk
andauthored
gh-91217: deprecate spwd (#91846)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 2889042 commit 692e907

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

Doc/whatsnew/3.11.rst

+1
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ Deprecated
929929
* :mod:`ossaudiodev`
930930
* :mod:`pipes`
931931
* :mod:`sndhdr`
932+
* :mod:`spwd`
932933

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

Lib/test/test_spwd.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import os
22
import unittest
33
from test.support import import_helper
4+
import warnings
45

56

6-
spwd = import_helper.import_module('spwd')
7+
with warnings.catch_warnings():
8+
warnings.simplefilter("ignore", DeprecationWarning)
9+
spwd = import_helper.import_module('spwd')
710

811

912
@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate the spwd module.

Modules/spwdmodule.c

+7
Original file line numberDiff line numberDiff line change
@@ -256,5 +256,12 @@ static struct PyModuleDef spwdmodule = {
256256
PyMODINIT_FUNC
257257
PyInit_spwd(void)
258258
{
259+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
260+
"'spwd' is deprecated and slated for removal in "
261+
"Python 3.13",
262+
7)) {
263+
return NULL;
264+
}
265+
259266
return PyModuleDef_Init(&spwdmodule);
260267
}

0 commit comments

Comments
 (0)