Commit 8df2c28
fix(dbapi): bundle D — input validation, PEP 249 wrapping, cleanups
Nine issues from cycle 3 bundle D, all in the dbapi layer.
Input validation:
- ISSUE-82: fetchmany() rejects negative size with ProgrammingError
rather than silently returning [] (range(-5) is empty). Mirror the
arraysize-setter's >= 1 guard on the sync+async cursors.
- ISSUE-86: _reject_non_sequence_params now rejects str/bytes/
bytearray/memoryview. They are iterable so qmark binding would
silently "explode" into per-character binds — almost always a
caller bug. Users should wrap in ``(value,)``.
Exception wrapping to satisfy PEP 249 "all DB errors funnel through
Error" contract:
- ISSUE-84: DateFromTicks / TimeFromTicks / TimestampFromTicks wrap
NaN/inf/out-of-range with DataError instead of leaking
ValueError/OverflowError/OSError.
- ISSUE-85: _call_client adds a trailing catch for DqliteError
subclasses not enumerated above. A future client exception class
cannot bypass PEP 249 wrapping.
- ISSUE-102: _datetime_from_iso8601 wraps parse failures in DataError.
- ISSUE-107: _datetime_from_unixtime wraps TypeError/OverflowError/
OSError/ValueError in DataError (malformed server payload).
Interface completions:
- ISSUE-80: add Cursor.rownumber / AsyncCursor.rownumber property
(PEP 249 optional). Returns the 0-based index of the next row or
None when no result set is active.
- ISSUE-88: Time() and Timestamp() accept optional microsecond and
tzinfo parameters for parity with stdlib datetime.time /
datetime.datetime. Mixing driver Time() with stdlib time() no
longer silently drops microsecond precision.
Cleanups:
- ISSUE-110: extract _is_row_returning(sql) helper at module level;
both sync and async cursors import it. Previously duplicated
inline in two places.
- ISSUE-113: narrow the three ``except Exception: pass`` blocks in
_cleanup_loop_thread to specific expected exceptions (RuntimeError).
Wider suppression hid programmer bugs during finalization.
Adds tests/test_cycle3_hardening.py with 32 regression tests across
these issues.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9974f33 commit 8df2c28
File tree
5 files changed
+372
-32
lines changed- src/dqlitedbapi
- aio
- tests
5 files changed
+372
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
67 | 78 | | |
68 | 79 | | |
69 | 80 | | |
| |||
94 | 105 | | |
95 | 106 | | |
96 | 107 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 108 | + | |
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
| |||
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
194 | 203 | | |
195 | 204 | | |
196 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | | - | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | | - | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
53 | | - | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
38 | 46 | | |
39 | 47 | | |
40 | 48 | | |
| |||
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
| |||
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
79 | | - | |
| 94 | + | |
80 | 95 | | |
81 | 96 | | |
82 | 97 | | |
83 | 98 | | |
84 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
85 | 103 | | |
86 | 104 | | |
87 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
88 | 112 | | |
89 | 113 | | |
90 | 114 | | |
| |||
124 | 148 | | |
125 | 149 | | |
126 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
127 | 171 | | |
128 | 172 | | |
129 | 173 | | |
| |||
183 | 227 | | |
184 | 228 | | |
185 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
186 | 243 | | |
187 | 244 | | |
188 | 245 | | |
| |||
216 | 273 | | |
217 | 274 | | |
218 | 275 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 276 | + | |
228 | 277 | | |
229 | 278 | | |
230 | 279 | | |
| |||
320 | 369 | | |
321 | 370 | | |
322 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
323 | 377 | | |
324 | 378 | | |
325 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
18 | 32 | | |
19 | 33 | | |
20 | 34 | | |
21 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
22 | 43 | | |
23 | 44 | | |
24 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
25 | 58 | | |
26 | 59 | | |
27 | 60 | | |
28 | 61 | | |
29 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
30 | 67 | | |
31 | 68 | | |
32 | 69 | | |
33 | 70 | | |
34 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
35 | 76 | | |
36 | 77 | | |
37 | 78 | | |
38 | 79 | | |
39 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
40 | 85 | | |
41 | 86 | | |
42 | 87 | | |
| |||
161 | 206 | | |
162 | 207 | | |
163 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
164 | 214 | | |
165 | 215 | | |
166 | 216 | | |
| |||
172 | 222 | | |
173 | 223 | | |
174 | 224 | | |
175 | | - | |
| 225 | + | |
176 | 226 | | |
177 | 227 | | |
178 | 228 | | |
| |||
181 | 231 | | |
182 | 232 | | |
183 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
184 | 238 | | |
185 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
186 | 243 | | |
187 | 244 | | |
188 | 245 | | |
| |||
0 commit comments