]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91217: deprecate spwd (#91846)
authorBrett Cannon <brett@python.org>
Sat, 23 Apr 2022 21:48:17 +0000 (14:48 -0700)
committerGitHub <noreply@github.com>
Sat, 23 Apr 2022 21:48:17 +0000 (14:48 -0700)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Doc/whatsnew/3.11.rst
Lib/test/test_spwd.py
Misc/NEWS.d/next/Library/2022-04-17-12-32-40.gh-issue-91217.ms49Rg.rst [new file with mode: 0644]
Modules/spwdmodule.c

index 5b53fbe0dda6ffb6e195f7d8b1f54ec466e2add0..34742515168c30621200db32955ac17ff114c8fb 100644 (file)
@@ -929,6 +929,7 @@ Deprecated
   * :mod:`ossaudiodev`
   * :mod:`pipes`
   * :mod:`sndhdr`
+  * :mod:`spwd`
 
   (Contributed by Brett Cannon in :issue:`47061`.)
 
index a143acc659ef6a54e8b4dc866615d76ec2bd3f92..50766c25482a61019970790a12ebd095ac5754e1 100644 (file)
@@ -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 (file)
index 0000000..9655522
--- /dev/null
@@ -0,0 +1 @@
+Deprecate the spwd module.
index acea30679bf5ec987ededd2efdeacaf927ff0ac9..42123c93b59365696ab00f474387f3ac51a29c81 100644 (file)
@@ -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);
 }