How can a type be incompatible with itself?

In my django application (Django 1.6.0, python 2.7.5 running on Red Hat), my database driver gets an error from ctypes:

TypeError: incompatible types, LP_c_int instance instead of LP_c_int instance

The code is as follows:

    is_null = value is None
    param.value.is_null = pointer(c_int(is_null)) <-- error occurs on this line

I am not very familiar with ctypes (I inherited this code), but on the surface this error message does not make sense. The code has been running for many years, but now I see this error everywhere. Am I doing something obviously wrong?

The following is the minimum report from the commentary of Elijah Everala:

from ctypes import *
from ctypes import _reset_cache

class DataValue(Structure):
    """Must match a_sqlany_data_value."""

    _fields_ = [("buffer",      POINTER(c_char)),
                ("buffer_size", c_size_t),
                ("length",      POINTER(c_size_t)),
                ("type",        c_int),
                ("is_null",     POINTER(c_int))]

d = DataValue()
_reset_cache()
is_null = False
d.is_null = pointer( c_int( is_null ) )
+4
source share

Source: https://habr.com/ru/post/1691644/


All Articles