[pypy-svn] r79441 - pypy/branch/gdbm/lib_pypy

dstromberg at codespeak.net dstromberg at codespeak.net
Wed Nov 24 01:07:59 CET 2010


Author: dstromberg
Date: Wed Nov 24 01:07:57 2010
New Revision: 79441

Modified:
   pypy/branch/gdbm/lib_pypy/gdbm.py
Log:
Convert from char * to str more carefully; this enables the gdbm.py module to pass anydbm's tests.


Modified: pypy/branch/gdbm/lib_pypy/gdbm.py
==============================================================================
--- pypy/branch/gdbm/lib_pypy/gdbm.py	(original)
+++ pypy/branch/gdbm/lib_pypy/gdbm.py	Wed Nov 24 01:07:57 2010
@@ -50,7 +50,11 @@
 
     def __str__(self):
         char_star = ctypes.cast(self.dptr, ctypes.POINTER(ctypes.c_char))
-        return char_star[:self.dsize]
+		  # we can't just slice a char *, so we convert to str, one character (byte) at a time
+        result = []
+        for index in xrange(self.dsize):
+            result.append(char_star[index])
+        return ''.join(result)
 
     def __enter__(self):
         self.free_when_done = True



More information about the Pypy-commit mailing list