This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: non defined representation for pwd.struct_passwd
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, benjamin.peterson, eric.araujo, fgarciar, r.david.murray
Priority: normal Keywords:

Created on 2011-06-25 15:54 by fgarciar, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg139090 - (view) Author: Francisco Garcia (fgarciar) Date: 2011-06-25 15:54
pwd.struct_passwd has different representations in cpython 2.7.2 and pypy 1.5

A unit test from cpython might enforce the same representation across interpreters:

>>> print pwd.getpwuid(os.getuid())

Current cpython output:

pwd.struct_passwd(pw_name='demo_user', pw_passwd='********', pw_uid=1001, pw_gid=100, pw_gecos='demo_user', pw_dir='/Users/demo_user', pw_shell='/bin/bash')

Current pypy output
('demo_user', '********', 1001, 100, 'demo_user', '/Users/demo_user', '/bin/bash')
msg139094 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-25 16:15
Looks like the difference between a regular tuple and a named tuple.  The correct test is to access the members using the names, and the test suite currently does this.  The repr shouldn't, I think, be required to be identical.

On the other hand, if pypy is implementing named tuples and the repr doesn't include the names, perhaps there is a missing test in the tests of named tuples.
msg139650 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-02 13:56
The docs indeed don’t say more that “Password database entries are reported as a tuple-like object, whose attributes correspond to the members of the passwd structure”; no mention is made of named tuple or struct sequence.

I think there is no bug for CPython; you may want to suggest friendlier reprs for structseqs to PyPy.
msg139692 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-07-03 17:18
pypy did not use a structseq in this case. Fixed in (pypy's repo) dded6e510044
msg139694 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-07-03 17:47
But pypy passed the attribute access tests in the test suite?
msg140274 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-13 15:34
Actually, I’ve found that there are some structseq’s repr that get tested in the CPython test suite.
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56621
2011-07-13 15:34:39eric.araujosetmessages: + msg140274
2011-07-03 17:47:41r.david.murraysetmessages: + msg139694
2011-07-03 17:18:06amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg139692
2011-07-02 13:56:24eric.araujosetstatus: open -> closed

nosy: + eric.araujo, benjamin.peterson
messages: + msg139650

resolution: works for me
stage: resolved
2011-06-25 16:15:57r.david.murraysetnosy: + r.david.murray
messages: + msg139094
2011-06-25 15:54:49fgarciarcreate