Commits

Armin Rigo committed 13efcfa

More precise test: can call c_bool(anything). Fix for the whole test.

  • Participants
  • Parent commits 7071823

Comments (0)

Files changed (2)

File lib_pypy/_ctypes/primitive.py

                 self._buffer[0] = value
             result.value = property(_getvalue, _setvalue)
 
+        elif tp == '?':  # regular bool
+            def _getvalue(self):
+                return bool(self._buffer[0])
+            def _setvalue(self, value):
+                self._buffer[0] = bool(value)
+            result.value = property(_getvalue, _setvalue)
+
         elif tp == 'v': # VARIANT_BOOL type
             def _getvalue(self):
                 return bool(self._buffer[0])

File pypy/module/test_lib_pypy/ctypes_tests/test_cast.py

         assert x.value is True
         x = c_bool(0.0)
         assert x.value is False
+        x = c_bool("")
+        assert x.value is False
+        x = c_bool(['yadda'])
+        assert x.value is True