]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#18678: Correct names of spwd struct members.
authorR David Murray <rdmurray@bitdance.com>
Mon, 4 Nov 2013 00:54:05 +0000 (19:54 -0500)
committerR David Murray <rdmurray@bitdance.com>
Mon, 4 Nov 2013 00:54:05 +0000 (19:54 -0500)
The old names (sp_nam and sp_pwd) are kept for backward compatibility.  Since
this is a long standing bug that hasn't caused any real-world problems, I'm
not backporting it.  However, it is worth fixing because the corrected names
match the documentation, and more importantly now match the C struct, just
like the other struct members.

Patch by Vajrasky Kok.

Doc/library/spwd.rst
Misc/NEWS
Modules/spwdmodule.c

index add611f09ea16ec9282425800fd341edf750c26b..58be78f0175916c900fb153c79c6e41521ab0340 100644 (file)
@@ -19,9 +19,9 @@ below, see ``<shadow.h>``):
 +-------+---------------+---------------------------------+
 | Index | Attribute     | Meaning                         |
 +=======+===============+=================================+
-| 0     | ``sp_nam``    | Login name                      |
+| 0     | ``sp_namp``   | Login name                      |
 +-------+---------------+---------------------------------+
-| 1     | ``sp_pwd``    | Encrypted password              |
+| 1     | ``sp_pwdp``   | Encrypted password              |
 +-------+---------------+---------------------------------+
 | 2     | ``sp_lstchg`` | Date of last change             |
 +-------+---------------+---------------------------------+
@@ -36,15 +36,15 @@ below, see ``<shadow.h>``):
 +-------+---------------+---------------------------------+
 | 6     | ``sp_inact``  | Number of days after password   |
 |       |               | expires until account is        |
-|       |               | blocked                         |
+|       |               | disabled                        |
 +-------+---------------+---------------------------------+
 | 7     | ``sp_expire`` | Number of days since 1970-01-01 |
-|       |               | until account is disabled       |
+|       |               | when account expires            |
 +-------+---------------+---------------------------------+
 | 8     | ``sp_flag``   | Reserved                        |
 +-------+---------------+---------------------------------+
 
-The sp_nam and sp_pwd items are strings, all others are integers.
+The sp_namp and sp_pwdp items are strings, all others are integers.
 :exc:`KeyError` is raised if the entry asked for cannot be found.
 
 The following functions are defined:
index 8d32371f7bfb4b5dc84287a821e428344ada85d3..13f6b70b146820565f475edb6dd989035a7221c0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #18678: Corrected spwd struct member names in spwd module:
+  sp_nam->sp_namp, and sp_pwd->sp_pwdp.  The old names are kept as extra
+  structseq members, for backward compatibility.
+
 - Issue #6157: Fixed tkinter.Text.debug().  tkinter.Text.bbox() now raises
   TypeError instead of TclError on wrong number of arguments.  Original patch
   by Guilherme Polo.
index d06f8cecd1ba88e13cf15ed24a6dce84031c3df3..68ea1b5ea4af2de24643b5b7bf1c1bef8d831004 100644 (file)
@@ -26,22 +26,24 @@ You have to be root to be able to use this module.");
 #if defined(HAVE_GETSPNAM) || defined(HAVE_GETSPENT)
 
 static PyStructSequence_Field struct_spwd_type_fields[] = {
-    {"sp_nam", "login name"},
-    {"sp_pwd", "encrypted password"},
+    {"sp_namp", "login name"},
+    {"sp_pwdp", "encrypted password"},
     {"sp_lstchg", "date of last change"},
     {"sp_min", "min #days between changes"},
     {"sp_max", "max #days between changes"},
     {"sp_warn", "#days before pw expires to warn user about it"},
-    {"sp_inact", "#days after pw expires until account is blocked"},
-    {"sp_expire", "#days since 1970-01-01 until account is disabled"},
+    {"sp_inact", "#days after pw expires until account is disabled"},
+    {"sp_expire", "#days since 1970-01-01 when account expires"},
     {"sp_flag", "reserved"},
+    {"sp_nam", "login name; deprecated"}, /* Backward compatibility */
+    {"sp_pwd", "encrypted password; deprecated"}, /* Backward compatibility */
     {0}
 };
 
 PyDoc_STRVAR(struct_spwd__doc__,
 "spwd.struct_spwd: Results from getsp*() routines.\n\n\
 This object may be accessed either as a 9-tuple of\n\
-  (sp_nam,sp_pwd,sp_lstchg,sp_min,sp_max,sp_warn,sp_inact,sp_expire,sp_flag)\n\
+  (sp_namp,sp_pwdp,sp_lstchg,sp_min,sp_max,sp_warn,sp_inact,sp_expire,sp_flag)\n\
 or via the object attributes as named in the above tuple.");
 
 static PyStructSequence_Desc struct_spwd_type_desc = {
@@ -86,6 +88,8 @@ static PyObject *mkspent(struct spwd *p)
     SETI(setIndex++, p->sp_inact);
     SETI(setIndex++, p->sp_expire);
     SETI(setIndex++, p->sp_flag);
+    SETS(setIndex++, p->sp_namp); /* Backward compatibility for sp_nam */
+    SETS(setIndex++, p->sp_pwdp); /* Backward compatibility for sp_pwd */
 
 #undef SETS
 #undef SETI