[issue32033] The pwd test test_values fails on Android

Xavier de Gaye report at bugs.python.org
Wed Nov 15 05:34:19 EST 2017


New submission from Xavier de Gaye <xdegaye at gmail.com>:

On Android API 24:

$ python -c "import pwd; print(pwd.getpwuid(0))"
pwd.struct_passwd(pw_name='root', pw_passwd='', pw_uid=0, pw_gid=0, pw_gecos=None, pw_dir='/', pw_shell='/system/bin/sh')

The pw_gecos member is None and the test_values test of pwd fails because it expects a string. The fix is either (1) to skip the pw_gecos check in test_values for Android or (2) to modify the sets() function in Modules/pwdmodule.c to set an empty string instead of None when the member of the passwd structure is a NULL pointer.

POSIX [1] does not specify what are the possible values of the members of the struct passwd. GNU libc states that pw_dir and pw_shell may be NULL pointers so it seems that sets() is broken in these two cases.

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/getpwnam.html
[2] https://www.gnu.org/software/libc/manual/html_node/User-Data-Structure.html#User-Data-Structure

----------
components: Extension Modules, Tests
messages: 306261
nosy: haypo, serhiy.storchaka, xdegaye
priority: normal
severity: normal
stage: needs patch
status: open
title: The pwd test test_values fails on Android
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32033>
_______________________________________


More information about the Python-bugs-list mailing list