← 返回首页
gh-100450: Add `sqlite.Row.__contains__` method by sobolevn · Pull Request #100457 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-100450: Add sqlite.Row.__contains__ method#100457

Closed
sobolevn wants to merge 4 commits into
python:mainfrom
sobolevn:issue-100450
Closed

gh-100450: Add sqlite.Row.__contains__ method#100457
sobolevn wants to merge 4 commits into
python:mainfrom
sobolevn:issue-100450

Conversation

sobolevn commented Dec 23, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

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 Hide comment

I left some nitpicks. Also, please add tests.

Comment thread Modules/_sqlite/row.c Outdated
static int
pysqlite_row_contains(pysqlite_Row* self, PyObject *arg)
{
Py_ssize_t nitems, i;

Copy link
Copy Markdown
Contributor

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 Hide comment

Please use intermingled declarations :)

Comment thread Modules/_sqlite/row.c Outdated
for (i = 0; cmp == 0 && i < nitems; i++) {
cmp = PyObject_RichCompareBool(
arg,
PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0),

Copy link
Copy Markdown
Contributor

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 Hide comment

There's a lot happening on this line. I'd prefer it if you extracted these items before calling PyObject_RichCompareBool, for improved readability.

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Copy Markdown
Contributor

@erlend-aasland Hmm, is this whole thing not wrong anyway? (See my comment in the issue thread.)

Copy link
Copy Markdown
Member Author

@erlend-aasland

Also, please add tests.

I've added two doctests, aren't they enough?
If not, I don't know what is the best place for these tests. I can make new file for Row tests 🤔

Copy link
Copy Markdown
Contributor

I've added two doctests, aren't they enough? If not, I don't know what is the best place for these tests.

The doctests are there to make sure the examples in the docs actually work; it is not the place for unit tests. The unit tests (and regression tests, functional tests, etc.) all live in Lib/test/test_sqlite3. Their purpose is to test the _sqlite extension module (and the sqlite3 module) in all possible ways; we aim for as high code coverage as possible.

If I want to check the code coverage of the _sqlite C code, I can do so easily with a couple of compiler/linker flags, running ./python.exe -m test test_sqlite3, and generate a report.

Also, I'm not sure the buildbots run doctests; IIRC, they only run the test suite, but I might be wrong about this.

Copy link
Copy Markdown
Member Author

Sure, @erlend-aasland, I've added a unit test :)

Copy link
Copy Markdown
Contributor

Sure, @erlend-aasland, I've added a unit test :)

Thanks! BTW; I haven't decided if this is a good thing to add, or not. But lets keep that conversation on the issue. I'm going to mark this with do-not-merge until the discussion has landed.

Comment thread Lib/test/test_sqlite3/test_factory.py Show resolved Hide resolved

vsajip commented Dec 24, 2022

Copy link
Copy Markdown
Member

I haven't decided if this is a good thing to add

Should we open this to wider discussion on Discourse/Core development?

Copy link
Copy Markdown
Contributor

Yeah, IMO it is worth it trying to gather more feedback on Discourse.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Footer

© 2026 GitHub, Inc.