Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-44859: Raise more accurate exceptions insqlite3#27695

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 16 commits intopython:mainfromerlend-aasland:sqlite-errors
Mar 17, 2022

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aaslanderlend-aasland commentedAug 9, 2021
edited
Loading

Improve exception compliancy with PEP 249

  • Raise InterfaceError instead of ProgrammingError for SQLITE_MISUSE.
    If SQLITE_MISUSE is raised, it is a sqlite3 module bug. Users of the
    sqlite3 module are not responsible of using the SQLite C API correctly.
  • Don't overwrite BufferError with ValueError when conversion to BLOB fails.
  • Raise ProgrammingError instead of Warning if user tries to execute() more
    than one SQL statement.
  • Raise ProgrammingError instead of ValueError if an SQL query contains null characters.
  • Make sure_pysqlite_set_result raises an exception if it returns -1.

Fixes#89022

@erlend-aasland
Copy link
ContributorAuthor

@serhiy-storchaka would you mind reviewing this?

@erlend-aasland
Copy link
ContributorAuthor

@serhiy-storchaka PTAL. I just fixed bug in_pysqlite_set_result that could result in a segfault.

@erlend-aasland
Copy link
ContributorAuthor

@malemburg would you mind taking a look at this PR? I'm slowly trying to align the exceptions raised with PEP 249.

@JelleZijlstra
Copy link
Member

Looks like you didn't push the changes I previously asked for.

@erlend-aasland
Copy link
ContributorAuthor

Looks like you didn't push the changes I previously asked for.

Actually, it seems I forgot about this; I didn't make any changes yet :) I'll see if I can get to it any time soon. Thanks for the reminder!

@erlend-aasland
Copy link
ContributorAuthor

I'd like to run this through the Django test suite before eventually merging. Also, I'll have a talk with MAL regarding this change.

@erlend-aasland
Copy link
ContributorAuthor

erlend-aasland commentedMar 2, 2022
edited
Loading

I'd like to run this through the Django test suite before eventually merging. Also, I'll have a talk with MAL regarding this change.

I finally got to run this through the Django test suite, and it works all fine; one down, one to go.

Observations while running the Django test suite

I got sidetracked with a long bisect operation because I was using SQLite 3.39.0 (development version), and becauseb899126 produces a ton of warnings in the Django test suite. I revertedb899126 and compiled strictly against SQLite 3.36.0 (macOS bundled), and all was ok.

UPDATE: I had a chat the other day with@malemburg, to get his comments regarding three specific DB-API related changes in this PR. I take the liberty to quote him here (hope that's ok, Marc-Andre):

  1. RaiseInterfaceError iso.ProgrammingError forSQLITE_MISUSE. IfSQLITE_MISUSE is raised, it is a sqlite3 module bug. Users of the sqlite3 module are not responsible of using the SQLite C API correctly.

    This sounds fine. InterfaceError is meant for module related errors.

  2. RaiseProgrammingError iso.Warning if user tries toexecute() more than one statement

    Yep, sounds fine.

  3. RaiseDataError iso.ValueError if query containsNULL characters

    Since queries are passed in by the programmer, I would use ProgrammingError here. DataError would be appropriate for errors related to e.g. wrong values passed in as bound parameters.

I will update the PR with the suggested change.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

@berkerpeksagberkerpeksagAwaiting requested review from berkerpeksagberkerpeksag is a code owner

@serhiy-storchakaserhiy-storchakaAwaiting requested review from serhiy-storchaka

@malemburgmalemburgAwaiting requested review from malemburg

Assignees

@JelleZijlstraJelleZijlstra

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Improve some sqlite3 errors

4 participants

@erlend-aasland@JelleZijlstra@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp