Closed emmanuelito closed 1 month ago
In Numpy 2 it looks like they changed the repr()
of these types, as well as the MRO. float64
fails for the different repr()
, float32
fails because it doesn't inherit from float
.
Numpy 1.x support was only accidental and not tested; it worked because these types had both repr and MRO compatible with Python floats. Therefore, registering an adapter is the only supported way. Maybe, in your adapter, return AsIs(str(numpy_float))
would be better.
Psycopg 3.2 has official support for numpy scalars and it is tested for both numpy version <2 and 2. We are not planning to add builtin support in psycopg2.
Please complete the following information:
Describe the bug
Migrating from Numpy 1.26. The following was working:
Under NumPy 2.0.1 the code raises
which is quite obscure.
Whereas if we change the type to
np.float32
we gat another, more explicit, exception:By the way, the above code (but not the strange exception message) is fixed by adding