Message281176
By moving:
```
/* else set the right exception and return NULL */
PyErr_SetString(pysqlite_ProgrammingError, "can't adapt");
```
from `pysqlite_microprotocols_adapt` to `pysqlite_adapt` (to avoid changing the semantics from the outside) make the `pysqlite_microprotocols_adapt`protocol clearer:
- if it went well return something
- If it went well but had nothing to do: return NULL
- If it broke, set an exception and return NULL
It does not break any test. Then in `Modules/_sqlite/statement.c`, we can stop blindly muting exceptions with the `PyErr_Clear`s, replacing them with ``if (PyErr_Occurred()) return;``. Again it does not break any test.
I added a test to check that if an adapter raises an exception it bubbles outside the execute method, and it passes.
Sample code given by the issue now gives::
$ ./python issue28729.py
Traceback (most recent call last):
File "issue28729.py", line 18, in <module>
cur.execute("select ?", (p,))
File "issue28729.py", line 10, in adapt_point
assert False, 'Problem in adapter'
AssertionError: Problem in adapter
I did not found precise documentation about pysqlite_microprotocols_adapt or pysqlite_adapt, so my changes may break a "well known protocol", but it looks safe as I do not change the _sqlite protocol as far as I can tell, (only when the exception comes directly from the adaptor, obviously), and there were no other uses of pysqlite_microprotocols_adapt, which is not exposed in the module. |
|
Date |
User |
Action |
Args |
2016-11-18 22:40:09 | mdk | set | recipients:
+ mdk, inglesp |
2016-11-18 22:40:09 | mdk | set | messageid: <1479508809.88.0.848909305689.issue28729@psf.upfronthosting.co.za> |
2016-11-18 22:40:09 | mdk | link | issue28729 messages |
2016-11-18 22:40:09 | mdk | create | |
|