[Python-checkins] gh-91217: deprecate nis (GH-91606)

miss-islington webhook-mailer at python.org
Sat Apr 16 16:17:34 EDT 2022


https://github.com/python/cpython/commit/9f06ff96ccbda25c447b6a6f94082ea1e7784d96
commit: 9f06ff96ccbda25c447b6a6f94082ea1e7784d96
branch: main
author: Brett Cannon <brett at python.org>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-04-16T13:17:30-07:00
summary:

gh-91217: deprecate nis (GH-91606)



Automerge-Triggered-By: GH:brettcannon

files:
A Misc/NEWS.d/next/Library/2022-04-16-09-33-14.gh-issue-91217.nt9JFs.rst
M Doc/whatsnew/3.11.rst
M Lib/test/test_nis.py
M Modules/nismodule.c

diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index cd452fc537157..bedf80a72fab5 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -882,6 +882,7 @@ Deprecated
   * :mod:`crypt`
   * :mod:`imghdr`
   * :mod:`msilib`
+  * :mod:`nis`
   * :mod:`nntplib`
 
   (Contributed by Brett Cannon in :issue:`47061`.)
diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py
index a22142f4069ba..797c9023ad34d 100644
--- a/Lib/test/test_nis.py
+++ b/Lib/test/test_nis.py
@@ -1,10 +1,13 @@
 from test import support
 from test.support import import_helper
 import unittest
+import warnings
 
 
 # Skip test if nis module does not exist.
-nis = import_helper.import_module('nis')
+with warnings.catch_warnings():
+    warnings.simplefilter("ignore", DeprecationWarning)
+    nis = import_helper.import_module('nis')
 
 
 class NisTests(unittest.TestCase):
diff --git a/Misc/NEWS.d/next/Library/2022-04-16-09-33-14.gh-issue-91217.nt9JFs.rst b/Misc/NEWS.d/next/Library/2022-04-16-09-33-14.gh-issue-91217.nt9JFs.rst
new file mode 100644
index 0000000000000..fc29034169866
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-04-16-09-33-14.gh-issue-91217.nt9JFs.rst
@@ -0,0 +1 @@
+Deprecate the nis module.
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index cdda1a6a2fb7d..948f756935db5 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -524,5 +524,11 @@ static struct PyModuleDef nismodule = {
 PyMODINIT_FUNC
 PyInit_nis(void)
 {
+    if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                     "'nis' is deprecated and slated for removal in "
+                     "Python 3.13",
+                     7)) {
+        return NULL;
+    }
     return PyModuleDef_Init(&nismodule);
 }



More information about the Python-checkins mailing list