Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-16379: expose SQLite error codes and error names in sqlite3#27786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-16379: expose SQLite error codes and error names in sqlite3#27786
Uh oh!
There was an error while loading. Please reload this page.
Conversation
erlend-aasland commented Aug 16, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
- 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. |
erlend-aasland commented Aug 19, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
FYI, I pushed a small tweak to the unit test: use the Thanks for reviewing, @auvipy |
| int | ||
| _pysqlite_seterror(pysqlite_state*state, sqlite3*db) | ||
| staticPyObject* | ||
| get_exception_class(pysqlite_state*state, interrorcode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I see now that it can be a bit confusing. I'll add a comment. Thanks!
erlend-aaslandAug 25, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
erlend-aasland commented Aug 25, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pablogsal left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Good work!
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