Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
BTrees
Commits
bccbdf8b
Commit
bccbdf8b
authored
May 06, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix setting _p_changed when removing from small BTrees/TreeSets. The fix for #11 was incomplete.
parent
fc5e6662
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
3 deletions
+74
-3
BTrees/_base.py
BTrees/_base.py
+6
-0
BTrees/tests/common.py
BTrees/tests/common.py
+62
-0
CHANGES.rst
CHANGES.rst
+6
-3
No files found.
BTrees/_base.py
View file @
bccbdf8b
...
...
@@ -942,6 +942,12 @@ class _Tree(_Base):
removed_first_bucket
,
value
=
child
.
_del
(
key
)
# See comment in _set about small trees
if
(
len
(
data
)
==
1
and
child
.
__class__
is
self
.
_bucket_type
and
child
.
_p_oid
is
None
):
self
.
_p_changed
=
True
# fix up the node key, but not for the 0'th one.
if
index
>
0
and
child
.
size
and
key
==
data
[
index
].
key
:
self
.
_p_changed
=
True
...
...
BTrees/tests/common.py
View file @
bccbdf8b
...
...
@@ -1146,6 +1146,37 @@ class BTreeTests(MappingBase):
self
.
assertTrue
(
t
.
_p_changed
)
self
.
assertEqual
(
t
,
t
.
_p_jar
.
registered
)
def
testRemoveInSmallMapSetsChanged
(
self
):
# A bug in the BTree Python implementation once caused
# deleting from a small btree to set _p_changed
t
=
self
.
_makeOne
()
# Note that for the property to actually hold, we have to fake a
# _p_jar and _p_oid
t
.
_p_oid
=
b'
\
0
\
0
\
0
\
0
\
0
'
class
Jar
(
object
):
def
__init__
(
self
):
self
.
_cache
=
self
self
.
registered
=
None
def
mru
(
self
,
arg
):
pass
def
readCurrent
(
self
,
arg
):
pass
def
register
(
self
,
arg
):
self
.
registered
=
arg
t
.
_p_jar
=
Jar
()
t
[
0
]
=
1
# reset these, setting _firstbucket triggered a change
t
.
_p_changed
=
False
t
.
_p_jar
.
registered
=
None
# now remove the second value
del
t
[
0
]
self
.
assertTrue
(
t
.
_p_changed
)
self
.
assertEqual
(
t
,
t
.
_p_jar
.
registered
)
class
NormalSetTests
(
Base
):
# Test common to all set types
...
...
@@ -1354,6 +1385,37 @@ class NormalSetTests(Base):
pass
self
.
assertEqual
(
x
,
keys
)
def
testRemoveInSmallSetSetsChanged
(
self
):
# A bug in the BTree TreeSet Python implementation once caused
# deleting an item in a small set to fail to set _p_changed
t
=
self
.
_makeOne
()
# Note that for the property to actually hold, we have to fake a
# _p_jar and _p_oid
t
.
_p_oid
=
b'
\
0
\
0
\
0
\
0
\
0
'
class
Jar
(
object
):
def
__init__
(
self
):
self
.
_cache
=
self
self
.
registered
=
None
def
mru
(
self
,
arg
):
pass
def
readCurrent
(
self
,
arg
):
pass
def
register
(
self
,
arg
):
self
.
registered
=
arg
t
.
_p_jar
=
Jar
()
t
.
add
(
0
)
# reset these, setting _firstbucket triggered a change
t
.
_p_changed
=
False
t
.
_p_jar
.
registered
=
None
# now remove the second value
t
.
remove
(
0
)
self
.
assertTrue
(
t
.
_p_changed
)
self
.
assertEqual
(
t
,
t
.
_p_jar
.
registered
)
class
ExtendedSetTests
(
NormalSetTests
):
def
testLen
(
self
):
...
...
CHANGES.rst
View file @
bccbdf8b
...
...
@@ -4,7 +4,9 @@
4.1.3 (unreleased)
------------------
- TBD
- Fix _p_changed when removing items from small pure-Python
BTrees/TreeSets. See:
https://github.com/zopefoundation/BTrees/issues/13
4.1.2 (2015-04-07)
...
...
@@ -13,8 +15,9 @@
- Suppress testing 64-bit values in OLBTrees on 32 bit machines.
See: https://github.com/zopefoundation/BTrees/issues/9
- Fix _p_changed for small pure-Python BTrees.
See https://github.com/zopefoundation/BTrees/issues/11
- Fix _p_changed when adding items to small pure-Python
BTrees/TreeSets. See:
https://github.com/zopefoundation/BTrees/issues/11
4.1.1 (2014-12-27)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment