[New-bugs-announce] [issue17676] spwd uses -1 for empty attributes

Alex Waite report at bugs.python.org
Tue Apr 9 15:28:48 CEST 2013

New submission from Alex Waite:

spwd uses -1 rather than '' for empty attributes. This is different from the behaviour in the pwd module, and makes it more difficult to generate a new, valid shadow entry.

In my opinion, simply doing a ':'.join(str(val) for val in rec) should result in a valid entry. With pwd this is currently possible. Not so with spwd.

import pwd
rec = pwd.getpwnam('alex')
print ':'.join(str(val) for val in rec)

import spwd
rec = spwd.getspnam('alex')
shdw = ''
for idx, val in enumerate(recs_shdw):
    if idx != 0:
        shdw += ':'

    if val != -1:
        shdw += str(val)

print shdw

messages: 186402
nosy: Alexqw
priority: normal
severity: normal
status: open
title: spwd uses -1 for empty attributes
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list