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
e62d65d4
Commit
e62d65d4
authored
Oct 22, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent infinite loops in set operations.
Note that some tests are still failing in pure-Python mode.
parent
b868ad3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
BTrees/___BTree.py
BTrees/___BTree.py
+9
-6
No files found.
BTrees/___BTree.py
View file @
e62d65d4
...
@@ -341,6 +341,7 @@ class _MappingBase(_Base):
...
@@ -341,6 +341,7 @@ class _MappingBase(_Base):
set
(
*
i
)
set
(
*
i
)
def
__setitem__
(
self
,
key
,
value
):
def
__setitem__
(
self
,
key
,
value
):
# TODO: enforce test that key has non-default comparison?
self
.
_set
(
self
.
_to_key
(
key
),
self
.
_to_value
(
value
))
self
.
_set
(
self
.
_to_key
(
key
),
self
.
_to_value
(
value
))
def
__delitem__
(
self
,
key
):
def
__delitem__
(
self
,
key
):
...
@@ -1011,8 +1012,8 @@ def _set_operation(s1, s2,
...
@@ -1011,8 +1012,8 @@ def _set_operation(s1, s2,
if
MERGE_DEFAULT
is
not
None
:
if
MERGE_DEFAULT
is
not
None
:
i1
.
value
=
i2
.
value
=
MERGE_DEFAULT
i1
.
value
=
i2
.
value
=
MERGE_DEFAULT
else
:
else
:
if
i1
.
use
sValue
:
if
i1
.
use
Values
:
if
(
not
i2
.
use
sValue
)
and
c2
:
if
(
not
i2
.
use
Values
)
and
c2
:
raise
TypeError
(
"invalid set operation"
)
raise
TypeError
(
"invalid set operation"
)
else
:
else
:
if
c1
or
c12
:
if
c1
or
c12
:
...
@@ -1023,35 +1024,37 @@ def _set_operation(s1, s2,
...
@@ -1023,35 +1024,37 @@ def _set_operation(s1, s2,
def
copy
(
i
,
w
):
def
copy
(
i
,
w
):
r
.
_keys
.
append
(
i
.
key
)
r
.
_keys
.
append
(
i
.
key
)
r
.
_values
.
append
(
MERGE_WEIGHT
(
i
,
w
))
r
.
_values
.
append
(
MERGE_WEIGHT
(
i
,
w
))
i
.
advance
()
else
:
else
:
r
=
s1
.
_set_type
()
r
=
s1
.
_set_type
()
def
copy
(
i
,
w
):
def
copy
(
i
,
w
):
r
.
_keys
.
append
(
i
.
key
)
r
.
_keys
.
append
(
i
.
key
)
i
.
advance
()
while
i1
.
active
and
i2
.
active
:
while
i1
.
active
and
i2
.
active
:
cmp_
=
cmp
(
i1
.
key
,
i2
.
key
)
cmp_
=
cmp
(
i1
.
key
,
i2
.
key
)
if
cmp_
<
0
:
if
cmp_
<
0
:
if
c1
:
if
c1
:
copy
(
i1
,
w1
)
copy
(
i1
,
w1
)
i1
.
advance
()
elif
cmp_
==
0
:
elif
cmp_
==
0
:
if
c12
:
if
c12
:
r
.
_keys
.
append
(
i1
.
key
)
r
.
_keys
.
append
(
i1
.
key
)
if
merge
:
if
merge
:
r
.
_values
.
append
(
MERGE
(
i1
.
value
,
w1
,
i2
.
value
,
w2
))
r
.
_values
.
append
(
MERGE
(
i1
.
value
,
w1
,
i2
.
value
,
w2
))
i1
.
advance
()
i1
.
advance
()
i2
.
advance
()
i2
.
advance
()
else
:
else
:
if
c2
:
if
c2
:
copy
(
i2
,
w2
)
copy
(
i2
,
w2
)
i2
.
advance
()
if
c1
:
if
c1
:
while
i1
.
active
:
while
i1
.
active
:
copy
(
i1
,
w1
)
copy
(
i1
,
w1
)
i1
.
advance
()
if
c2
:
if
c2
:
while
i2
.
active
:
while
i2
.
active
:
copy
(
i2
,
w2
)
copy
(
i2
,
w2
)
i2
.
advance
()
return
r
return
r
...
...
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