GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-100450: Add `sqlite.Row.__contains__` method by sobolevn · Pull Request #100457 · python/cpython

Conversation

@sobolevn

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I went ahead and added it :)

CC @erlend-aasland and @vsajip

  • Issue: sqlite3.Row behaves like a dictionary but doesn't handle "in" as one might expect #100450

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vsajip reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@sobolevn
pythongh-100450: Add sqlite.Row.__contains__ method
62134f7
@sobolevn
sobolevn requested review from berkerpeksag and erlend-aasland as code owners December 23, 2022 11:41
@bedevere-bot bedevere-bot mentioned this pull request Dec 23, 2022
sqlite3.Row behaves like a dictionary but doesn't handle "in" as one might expect #100450
Closed
@bedevere-bot bedevere-bot added the awaiting review label Dec 23, 2022
@sobolevn
Remove cast
5b089dd
@sobolevn
sobolevn force-pushed the issue-100450 branch from 6ba3bdd to 5b089dd Compare December 23, 2022 11:58
erlend-aasland
erlend-aasland requested changes Dec 23, 2022
View reviewed changes

@erlend-aasland erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

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.

I left some nitpicks. Also, please add tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

@erlend-aasland erlend-aasland Dec 23, 2022

Copy link
Copy Markdown
Contributor

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.

Please use intermingled declarations :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
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),

@erlend-aasland erlend-aasland Dec 23, 2022

Copy link
Copy Markdown
Contributor

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot removed the awaiting review label Dec 23, 2022
@bedevere-bot

bedevere-bot commented Dec 23, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting changes label Dec 23, 2022
@pochmann

pochmann commented Dec 23, 2022

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn

sobolevn commented Dec 23, 2022

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 🤔

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
Address review
251d4bf
@erlend-aasland

erlend-aasland commented Dec 23, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
Add a unit test
5e419b5
@sobolevn

sobolevn commented Dec 23, 2022

Copy link
Copy Markdown
Member Author

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

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Dec 23, 2022

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.

sobolevn reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland erlend-aasland added the DO-NOT-MERGE label Dec 23, 2022
erlend-aasland
erlend-aasland reviewed Dec 23, 2022
View reviewed changes
Comment thread Lib/test/test_sqlite3/test_factory.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vsajip

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?

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Dec 26, 2022

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn sobolevn mentioned this pull request Dec 27, 2022
Improve test_sqlite3.test_sqlite_row_iter #100553
Closed
@sobolevn sobolevn closed this Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@erlend-aasland erlend-aasland erlend-aasland requested changes
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes DO-NOT-MERGE

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@sobolevn @bedevere-bot @pochmann @erlend-aasland @vsajip
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.