Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use stack level 7 ?

Copy link
Member Author

@brettcannon brettcannon Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be what it takes for the traceback to show the import statement and not some internal detail of importlib.

return NULL;
}

return PyModuleDef_Init(&spwdmodule);
}