Skip to content
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

fix persistency bug in the Python version #147

Merged
merged 4 commits into from
Nov 11, 2020
Merged

Conversation

d-maurer
Copy link
Contributor

@d-maurer d-maurer commented Nov 6, 2020

fixes #118

Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

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

LGTM.

Do you think it would be hard to write a regression test for this case?

CHANGES.rst Outdated Show resolved Hide resolved
@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 7, 2020 via email

@d-maurer d-maurer requested a review from mgedmin November 7, 2020 05:48
@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 7, 2020 via email

@mgedmin
Copy link
Member

mgedmin commented Nov 7, 2020

I don't think it would be good to target the pure-python implementation specifically; it'd be better to have a generic test for this case that gets run against both C and Python implementations.

We don't need to have a single test suite run cover all the implementations. We have multiple CI jobs for a reason, and some of them run with PURE_PYTHON=1.

If we're missing a job with PURE_PYTHON and w_zodb in Travis CI, let's add one! I don't particularly care about tox.ini, unless it would help writing that test to have an additional toxenv, in which case go right ahead!

@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 9, 2020

If we're missing a job with PURE_PYTHON and w_zodb in Travis CI, let's add one! I don't particularly care about tox.ini, unless it would help writing that test to have an additional toxenv, in which case go right ahead!

I have added a test.

When I run the test in isolation (PURE_PYTHON=1 python -m unittest discover -s BTrees -t . -p 'testPersist*.py') it correctly detects the problem (when the fix is not available) BUT tox -e w_zodb-pure does not. I suppose tox is not working as I expect: i.e. that a suffix -pure is not sufficient to get the envvar PURE_PYTHON set. Would be good if a tox expert could look into this.

@jugmac00
Copy link
Member

jugmac00 commented Nov 9, 2020

I have no time to lookup the exact syntax, but my gut feeling tells me this should work:

[testenv:{py35,w_zodb}-pure]
setenv =
    PURE_PYTHON=1

If you want to look it up yourself, search for "tox factors".

@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 9, 2020 via email

@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 9, 2020

The problem was not a missing PURE_PYTHON envvar but a missing dependency.

I assumed that the tox env w_zodb-pure would inherit the settings of env w_zodb. This is not the case. As a consequence w_zodb-pure lacked the ZODB dependency and the test (which requires the ZODB) was skipped.

I made several trials to cover both w_zodb and w_zodb-pure in a single section -- all failing. Finally, I used a copy of the w_zodb section to define w_zodb-pure.

Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

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

lgtm

def tearDown(self):
if self.db is not None:
self.db.close()
del self.db
Copy link
Member

Choose a reason for hiding this comment

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

Why this rather than, say, self.db = None?

@@ -3,7 +3,7 @@ envlist =
# Jython support pending 2.7 support, due 2012-07-15 or so. See:
# http://fwierzbicki.blogspot.com/2012/03/adconion-to-fund-jython-27.html
# py27,jython,pypy,coverage,docs
py27,py27-pure,py35,py35-pure,py36,py37,py38,pypy,pypy3,w_zodb,coverage,docs
py27,py27-pure,py35,py35-pure,py36,py37,py38,pypy,pypy3,w_zodb,w_zodb-pure,coverage,docs
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a .travis.yml job corresponding to this?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, AFAICT all of our Travis jobs include ZODB.

@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 9, 2020 via email

@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 9, 2020 via email

@mgedmin
Copy link
Member

mgedmin commented Nov 9, 2020

I wanted to restore the initial state (where db is defined
at class level).

Ah! I didn't realize that was the case

Of course self.db = None would have almost the same effect.

and would maybe avoid a possible bug in the future if somebody moves the class attribute into __init__ and doesn't realize they need to also update this code.

@d-maurer
Copy link
Contributor Author

d-maurer commented Nov 10, 2020 via email

@mgedmin
Copy link
Member

mgedmin commented Nov 10, 2020

This is a unittest.TestCase class.

I should stop reviewing code when I'm tired. I didn't even notice that!

I retract my comments on this.

@d-maurer d-maurer merged commit 21e428c into master Nov 11, 2020
@d-maurer d-maurer deleted the fix_py_persistency#118 branch November 11, 2020 05:38
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.

BTree "the bucket being iterated changed size"
3 participants