[pypy-svn] r45270 - in pypy/dist/pypy/module/posix: . test
fijal at codespeak.net
fijal at codespeak.net
Mon Jul 23 13:57:08 CEST 2007
Author: fijal
Date: Mon Jul 23 13:57:06 2007
New Revision: 45270
Modified:
pypy/dist/pypy/module/posix/__init__.py
pypy/dist/pypy/module/posix/interp_posix.py
pypy/dist/pypy/module/posix/test/test_posix2.py
Log:
Add os.uname
Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py (original)
+++ pypy/dist/pypy/module/posix/__init__.py Mon Jul 23 13:57:06 2007
@@ -79,8 +79,8 @@
interpleveldefs['execv'] = 'interp_posix.execv'
if hasattr(os, 'execve') and 0: # XXX XXX in-progress
interpleveldefs['execve'] = 'interp_posix.execve'
- #if hasattr(ctypes_posix, 'uname'):
- # interpleveldefs['uname'] = 'interp_posix.uname'
+ if hasattr(os, 'uname'):
+ interpleveldefs['uname'] = 'interp_posix.uname'
if hasattr(os, 'ttyname'):
interpleveldefs['ttyname'] = 'interp_posix.ttyname'
if hasattr(os, 'setsid'):
Modified: pypy/dist/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/dist/pypy/module/posix/interp_posix.py (original)
+++ pypy/dist/pypy/module/posix/interp_posix.py Mon Jul 23 13:57:06 2007
@@ -511,6 +511,19 @@
return space.wrap(result)
setsid.unwrap_spec = [ObjSpace]
+def uname(space):
+ """ uname() -> (sysname, nodename, release, version, machine)
+
+ Return a tuple identifying the current operating system.
+ """
+ try:
+ r = os.uname()
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ l_w = [space.wrap(i) for i in [r[0], r[1], r[2], r[3], r[4]]]
+ return space.newtuple(l_w)
+uname.unwrap_spec = [ObjSpace]
+
def declare_new_w_star(name):
if name in w_star_returning_int:
def WSTAR(space, status):
Modified: pypy/dist/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/dist/pypy/module/posix/test/test_posix2.py (original)
+++ pypy/dist/pypy/module/posix/test/test_posix2.py Mon Jul 23 13:57:06 2007
@@ -214,6 +214,14 @@
assert os.WIFSIGNALED(0) == False
assert os.WIFSIGNALED(1) == True
+ def test_os_uname(self):
+ os = self.posix
+ res = os.uname()
+ assert len(res) == 5
+ for i in res:
+ assert isinstance(i, str)
+ assert isinstance(res, tuple)
+
class AppTestEnvironment(object):
def setup_class(cls):
cls.space = space
More information about the Pypy-commit
mailing list