Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r47101:9efba345739c
Date: 2011-09-06 13:01 +0200
http://bitbucket.org/pypy/pypy/changeset/9efba345739c/

Log:    Cast these fields to a Python-level 'int', i.e. a C 'long'. This is
        the same as CPython does.

diff --git a/pypy/module/pwd/interp_pwd.py b/pypy/module/pwd/interp_pwd.py
--- a/pypy/module/pwd/interp_pwd.py
+++ b/pypy/module/pwd/interp_pwd.py
@@ -3,6 +3,7 @@
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.rlib.rarithmetic import intmask
 
 eci = ExternalCompilationInfo(
     includes=['pwd.h']
@@ -43,8 +44,8 @@
     w_tuple = space.newtuple([
         space.wrap(rffi.charp2str(pw.c_pw_name)),
         space.wrap(rffi.charp2str(pw.c_pw_passwd)),
-        space.wrap(pw.c_pw_uid),
-        space.wrap(pw.c_pw_gid),
+        space.wrap(intmask(pw.c_pw_uid)),
+        space.wrap(intmask(pw.c_pw_gid)),
         space.wrap(rffi.charp2str(pw.c_pw_gecos)),
         space.wrap(rffi.charp2str(pw.c_pw_dir)),
         space.wrap(rffi.charp2str(pw.c_pw_shell)),
diff --git a/pypy/module/pwd/test/test_pwd.py b/pypy/module/pwd/test/test_pwd.py
--- a/pypy/module/pwd/test/test_pwd.py
+++ b/pypy/module/pwd/test/test_pwd.py
@@ -14,6 +14,9 @@
         assert pw.pw_gid == 0
         assert pw.pw_dir == '/root'
         assert pw.pw_shell.startswith('/')
+        #
+        assert type(pw.pw_uid) is int
+        assert type(pw.pw_gid) is int
 
     def test_getpwnam(self):
         import pwd
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to