[pypy-svn] r45325 - pypy/dist/pypy/rpython/module

fijal at codespeak.net fijal at codespeak.net
Wed Jul 25 14:44:46 CEST 2007


Author: fijal
Date: Wed Jul 25 14:44:44 2007
New Revision: 45325

Modified:
   pypy/dist/pypy/rpython/module/ll_os.py
Log:
Be a bit more paranoid when kernel is trying to trick us into a segfault.
Anyway, makes rpython more happy.


Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py	(original)
+++ pypy/dist/pypy/rpython/module/ll_os.py	Wed Jul 25 14:44:44 2007
@@ -140,6 +140,14 @@
     os_uname = rffi.llexternal('uname', [UTSNAMEP], rffi.INT,
                                includes=['sys/utsname.h'])
 
+    def utcharp2str(cp):
+        l = []
+        i = 0
+        while cp[i] != '\x00' and i < lgt:
+            l.append(cp[i])
+            i += 1
+        return "".join(l)
+
     def uname_lltypeimpl():
         l_utsbuf = lltype.malloc(UTSNAMEP.TO, flavor='raw')
         result = os_uname(l_utsbuf)
@@ -147,7 +155,7 @@
             raise OSError(rffi.c_errno, "os_uname failed")
         fields = [l_utsbuf.c_sysname, l_utsbuf.c_nodename,
                 l_utsbuf.c_release, l_utsbuf.c_version, l_utsbuf.c_machine]
-        l = [rffi.charp2str(i) for i in fields]
+        l = [utcharp2str(i) for i in fields]
         retval = (l[0], l[1], l[2], l[3], l[4])
         lltype.free(l_utsbuf, flavor='raw')
         return retval



More information about the Pypy-commit mailing list