[issue17676] spwd uses -1 for empty attributes
Terry J. Reedy
report at bugs.python.org
Fri Apr 12 21:39:16 CEST 2013
Terry J. Reedy added the comment:
The docs for pwd and spwd modules specify that some items are strings and others are ints. Null strings should be '' and 'null' ints must be negative since 0 can be a valid item. It happens that all but 2 pwd items are strings and all but 2 spwd items are ints. The 2 pwd int items are uid and gid, which I believe are never missing, so you never encounter -1 for them. Similarly, the 2 spwd str items are nam and pwd, which I believe are not missing either, so you never encounter '' for them. Otherwise, your val != -1 test would not work.
I believe the following expression will work for spwd (and even pwd) (I cannot test on Windows ;-).
':'.join((str(val) if val != -1 else '') for val in rec)
----------
nosy: +terry.reedy
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17676>
_______________________________________
More information about the Python-bugs-list
mailing list