Closed coretl closed 10 months ago
I see two issues here:
Excellent, thanks for doing this, having the put builder exceptions propagate upwards will make it a lot easier to spot the problem in unit tests where pytest has swallowed stdout...
To make it clear, I wasn't regarding the existing casting behavior as a bug, just the lack of exception. Personally, I don't know whether I prefer the safe or unsafe casting rules. On the one hand np.ndarray([1,2,3])
looks like is should be allowed for an int32
field, but on the other hand np.ndarray([1.5, 2.5, 3.5])
probably shouldn't. I guess the new behavior will allow both and truncate the floats. Maybe I would argue that the safe rules are less surprising? Although I could be convinced otherwise...
To make it clear, I wasn't regarding the existing casting behavior as a bug ...
Understood. I however do look upon stronger coupling of data types between server and clients (I assume plural) as a potential maintenance problem. cf. the problems caused by older versions of normativeTypesCPP. So to my mind the default should be permissive, as is already the case for scalar values.
A client which wants to ensure fidelity can provide a put builder callback and inspect the types. Of course this is not so convenient. I could see adding a way to select stricter casting, although designing such an interface runs into some of the same problems as eg. timestamps wrt. the NT wrappers. (although maybe we don't bother with the wrappers initially)
I think this issue has been addressed.
When the Put builder fails, it is reported to the console, but the call to
Context.put
does not raise an exception. This was somewhat surprising!For example, when running a database:
With IOC
python -m epicscorelibs.ioc -d demo.db
, then running client script:I get the following output, showing the put fails but does not raise:
I get the same result if I use
p4p.client.asyncio
Running on Linux with python 3.10.6, p4p 4.1.9, pvxslibs 1.2.2, epicscorelibs 7.0.7.99.0.2