Uh oh!
There was an error while loading. Please reload this page.
bpo-16379: expose SQLite error codes and error names in sqlite3 - #27786
Conversation
- Naming: sqlite3ErrName => pysqlite_error_name - Error handling: * return NULL if no exception matched * receiver handles errors * don't use error table to store SQLITE_UNKNOWN string
- Use intermingled declarations - Simplify ref count handling
- Declutter add_error_constants() - No need to typedef struct - Simplify naming - Use PyModule_AddIntConstant
To avoid mismatch between char *name and constant
IMO, we should not pollute the SQLITE_* namespace
- Use correct attribute name - Normalise error variable naming - Remove 'Errno' from printed string to avoid confusion
- Use assertRaisesRegex iso. two assert functions - Normalise quotes - Test that constants are added to the module
erlend-aasland
commented
Aug 16, 2021
cc. @nedbat |
erlend-aasland
commented
Aug 16, 2021
cc. @auvipy & @matrixise who reviewed the original PR. |
FYI, I pushed a small tweak to the unit test: use the Thanks for reviewing, @auvipy |
| int | ||
| _pysqlite_seterror(pysqlite_state *state, sqlite3 *db) | ||
| static PyObject * | ||
| get_exception_class(pysqlite_state *state, int errorcode) |
There was a problem hiding this comment.
This is slighly confusing because normally returning NULL signifies an error. Could you please document this both on the call site and in this function? Otherwise the call site reads weirdly because
PyObject *exc_class = get_exception_class(state, errorcode);
if (exc_class == NULL) {
return errorcode;
}
seems that is handling an error
There was a problem hiding this comment.
Yes, I see now that it can be a bit confusing. I'll add a comment. Thanks!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
erlend-aasland
commented
Aug 30, 2021
Thanks Pablo, and you can thank @danielshahaf & @palaviv for the good work; I just "stole" it, rebased onto |
Original PR: GH-1108 (contributed by @palaviv, based on patches by @danielshahaf)
This PR is a rebase and rework of Aviv & Daniel's work.
Co-authored-by: Aviv Pavlivoda
Co-authored-by: Daniel Shahaf
Co-authored-by: Erlend E. Aasland
https://bugs.python.org/issue16379