Brian Kearns  committed 3bca589

test and fix lib_pypy.dbm handling of null characters (patch from antocuni)

  • Participants
  • Parent commits 8234f36

Comments (0)

Files changed (2)

File lib_pypy/

-from ctypes import Structure, c_char_p, c_int, c_void_p, CDLL
+from ctypes import Structure, c_char_p, c_int, c_void_p, CDLL, POINTER, c_char
 import ctypes.util
 import os, sys
 class datum(Structure):
     _fields_ = [
-    ('dptr', c_char_p),
+    ('dptr', POINTER(c_char)),
     ('dsize', c_int),

File pypy/module/test_lib_pypy/

 except ImportError, e:
+import sys
+if '__pypy__' not in sys.builtin_module_names:
+    skip("lib_pypy.dbm requires PyPy's ctypes")
 def test_get():
     path = str(udir.join('test_dbm_extra.test_get'))
     d =, 'c')
 def test_extra():
     py.test.raises(TypeError, dbm.datum, 123)
     py.test.raises(TypeError, dbm.datum, False)
+def test_null():
+    db ='test', 'c')
+    db['1'] = 'a\x00b'
+    db.close()
+    db ='test', 'r')
+    assert db['1'] == 'a\x00b'
+    db.close()