FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-16379: expose SQLite error codes and error names in `sqlite3` by erlend-aasland · Pull Request #27786 · python/cpython · GitHub

/ cpython Public

bpo-16379: expose SQLite error codes and error names in sqlite3 - #27786

Merged
pablogsal merged 34 commits into
python:mainfrom
erlend-aasland:sqlite-expose-error-code
Aug 30, 2021
Merged

bpo-16379: expose SQLite error codes and error names in sqlite3#27786
pablogsal merged 34 commits into
python:mainfrom
erlend-aasland:sqlite-expose-error-code

Conversation

erlend-aasland commented Aug 16, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

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

palaviv and others added 29 commits May 9, 2019 12:54
- 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

Copy link
Copy Markdown
Contributor Author

cc. @nedbat

Copy link
Copy Markdown
Contributor Author

cc. @auvipy & @matrixise who reviewed the original PR.

erlend-aasland commented Aug 19, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

FYI, I pushed a small tweak to the unit test: use the temp_dir helper iso. a hard coded path.

Thanks for reviewing, @auvipy

Comment thread Modules/_sqlite/util.c
int
_pysqlite_seterror(pysqlite_state *state, sqlite3 *db)
static PyObject *
get_exception_class(pysqlite_state *state, int errorcode)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, I see now that it can be a bit confusing. I'll add a comment. Thanks!

erlend-aasland Aug 25, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is it clearer with 3589a6a?

(FYI, I need to rebase onto main again bco. GH-26202)

erlend-aasland commented Aug 25, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

I'll sync with main after #27942 is merged. => synced with a3c45b6

Comment thread Modules/_sqlite/module.c Outdated
Comment thread Modules/_sqlite/module.c Outdated

pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

Good work!

pablogsal merged commit 86d8b46 into python:main Aug 30, 2021
erlend-aasland deleted the sqlite-expose-error-code branch August 30, 2021 19:04

Copy link
Copy Markdown
Contributor Author

Thanks Pablo, and you can thank @danielshahaf & @palaviv for the good work; I just "stole" it, rebased onto main and made some minor adjustments :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL