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
15da8c11
Commit
15da8c11
authored
Dec 14, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify tests for default comparison.
Fix them under Py3k.
parent
83029192
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
15 deletions
+17
-15
BTrees/objectkeymacros.h
BTrees/objectkeymacros.h
+5
-5
BTrees/tests/test_OOBTree.py
BTrees/tests/test_OOBTree.py
+12
-10
No files found.
BTrees/objectkeymacros.h
View file @
15da8c11
...
...
@@ -5,7 +5,7 @@
#include "Python.h"
#include "_compat.h"
static
PyObject
*
object_
;
static
PyObject
*
object_
;
/* initialized in BTreeModuleTemplate init */
static
int
check_argument_cmp
(
PyObject
*
arg
)
...
...
@@ -16,12 +16,12 @@ check_argument_cmp(PyObject *arg)
/* arg->ob_type->tp_compare, */
/* ((PyTypeObject *)object_)->ob_type->tp_compare); */
#ifdef PY3K
if
(
Py_TYPE
(
arg
)
->
tp_richcompare
==
Py_TYPE
(
object_
)
->
tp_richcompare
)
#else
if
(
Py_TYPE
(
arg
)
->
tp_richcompare
==
NULL
#ifndef PY3K
&&
Py_TYPE
(
arg
)
->
tp_compare
==
((
PyTypeObject
*
)
object_
)
->
ob_type
->
tp_compare
&&
Py_TYPE
(
arg
)
->
tp_compare
==
Py_TYPE
(
object_
)
->
tp_compare
)
#endif
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Object has default comparison"
);
return
0
;
...
...
BTrees/tests/test_OOBTree.py
View file @
15da8c11
...
...
@@ -112,6 +112,7 @@ class OOBTreeTest(BTreeTests, unittest.TestCase):
# used in a function that's used in lots of places.
# Otherwise, there are many permutations that would have to be
# checked.
from
.._compat
import
PY2
t
=
self
.
_makeOne
()
class
C
(
object
):
...
...
@@ -119,30 +120,31 @@ class OOBTreeTest(BTreeTests, unittest.TestCase):
self
.
assertRaises
(
TypeError
,
lambda
:
t
.
__setitem__
(
C
(),
1
))
class
C
(
object
):
def
__cmp__
(
*
args
):
return
1
if
PY2
:
# we only check for __cmp__ on Python2
c
=
C
()
t
[
c
]
=
1
class
With___cmp__
(
object
):
def
__cmp__
(
*
args
):
return
1
c
=
With___cmp__
()
t
[
c
]
=
1
t
.
clear
()
t
.
clear
()
class
C
(
object
):
class
With___lt__
(
object
):
def
__lt__
(
*
args
):
return
1
c
=
C
()
c
=
With___lt__
()
t
[
c
]
=
1
t
.
clear
()
#
class OOBTreePyTest(OOBTreeTest):
class
OOBTreePyTest
(
OOBTreeTest
):
#
# Right now, we can't match the C extension's test / prohibition of the
# default 'object' comparison semantics.
class
OOBTreePyTest
(
BTreeTests
,
unittest
.
TestCase
):
#
class OOBTreePyTest(BTreeTests, unittest.TestCase):
def
_makeOne
(
self
):
from
BTrees.OOBTree
import
OOBTreePy
...
...
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