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: test_grp and test_pwd fail with 32-bit builds on OS X systems
Type: behavior Stage: resolved
Components: Tests Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, ned.deily, python-dev, serhiy.storchaka
Priority: normal Keywords:

Created on 2013-03-23 20:00 by ned.deily, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (11)
msg185081 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-03-23 20:00
With the changes introduced for Issue4591, test_grp and test_pwd now fail on OS X systems when Python is run in 32-bit mode.

Previously, using a 64-bit/32-bit universal build of 2.7.3:

$ arch -i386 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nobody").gr_gid; print(g,type(g))'
(-2, <type 'int'>)
$ arch -x86_64 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nobody").gr_gid; print(g,type(g))'
(4294967294, <type 'int'>)

Now, with 2.7.4rc1:

$ arch -i386 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nobody").gr_gid; print(g,type(g))'
(4294967294L, <type 'long'>)
$ arch -x86_64 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nobody").gr_gid; print(g,type(g))'
(4294967294, <type 'int'>)

This results in test failures in both test_grp and test_pwd:

======================================================================
FAIL: test_values (test.test_grp.GroupDatabaseTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_grp.py", line 27, in test_values
    self.check_value(e)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_grp.py", line 19, in check_value
    self.assertIsInstance(value.gr_gid, int)
AssertionError: 4294967294L is not an instance of <type 'int'>

----------------------------------------------------------------------

======================================================================
FAIL: test_values (test.test_pwd.PwdTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_pwd.py", line 23, in test_values
    self.assertIsInstance(e.pw_gid, int)
AssertionError: 4294967294L is not an instance of <type 'int'>

----------------------------------------------------------------------
msg185082 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-03-23 20:12
Failure also seen on 32-bit buildbot:
http://buildbot.python.org/all/builders/x86%20Tiger%202.7
msg185084 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-23 20:24
New changeset 2aa817e0a645 by Benjamin Peterson in branch '2.7':
return int instead long when possible (#17531)
http://hg.python.org/cpython/rev/2aa817e0a645
msg185085 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-03-23 20:25
I hope that does it?
msg185086 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-03-23 20:32
No, that was wrong, sorry.
msg185087 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-03-23 20:41
I think the tests are wrong.
msg185088 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-23 20:41
New changeset c982393bea4e by Benjamin Peterson in branch '2.7':
group ids and user ids can be longs now (#17531)
http://hg.python.org/cpython/rev/c982393bea4e
msg185090 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-03-23 21:01
That fixes the test for nobody (-2). Now the next part of the test fails more seriously for nogroup (-1).  Simplifying:

2.7.3
$ arch -i386 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nogroup").gr_gid; print(grp.getgrgid(g),type(g))'
(grp.struct_group(gr_name='nogroup', gr_passwd='*', gr_gid=-1, gr_mem=[]), <type 'int'>)
$ arch -x86_64 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nogroup").gr_gid; print(grp.getgrgid(g),type(g))'
(grp.struct_group(gr_name='nogroup', gr_passwd='*', gr_gid=4294967295, gr_mem=[]), <type 'int'>)

2.7.4rc1:
$ arch -i386 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nogroup").gr_gid; print(grp.getgrgid(g),type(g))'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
OverflowError: group id is greater than maximum
$ arch -x86_64 /usr/local/bin/python2.7 -c 'import grp; g=grp.getgrnam("nogroup").gr_gid; print(grp.getgrgid(g),type(g))'
(grp.struct_group(gr_name='nogroup', gr_passwd='*', gr_gid=4294967295, gr_mem=[]), <type 'int'>)
msg185093 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-03-23 21:32
Whack, whack. a4dbe53577cb
msg185095 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-03-23 21:34
a4dbe53577cb appears to fix the latter problem.  Thanks!
msg185097 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-23 21:36
New changeset 87d266988905 by Benjamin Peterson in branch '2.7':
update NEWS for #17531
http://hg.python.org/cpython/rev/87d266988905
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61733
2013-03-23 21:36:22python-devsetmessages: + msg185097
2013-03-23 21:34:27ned.deilysetstatus: open -> closed
resolution: fixed
messages: + msg185095

stage: resolved
2013-03-23 21:32:34benjamin.petersonsetmessages: + msg185093
2013-03-23 21:01:39ned.deilysetmessages: + msg185090
2013-03-23 20:41:23python-devsetmessages: + msg185088
2013-03-23 20:41:20benjamin.petersonsetmessages: + msg185087
2013-03-23 20:32:07benjamin.petersonsetmessages: + msg185086
2013-03-23 20:25:11benjamin.petersonsetmessages: + msg185085
2013-03-23 20:24:42python-devsetnosy: + python-dev
messages: + msg185084
2013-03-23 20:12:13ned.deilysetmessages: + msg185082
2013-03-23 20:00:15ned.deilycreate