Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Zope
Commits
f6669501
Commit
f6669501
authored
Jun 13, 2008
by
Ranjith Kannikara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The Wrapper_compare function from tp_compare to tp_richcompare.
Also another function Wrapper_richcompare is added.
parent
d11aab51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/Acquisition/_Acquisition.c
lib/python/Acquisition/_Acquisition.c
+35
-2
No files found.
doc/CHANGES.txt
View file @
f6669501
...
@@ -416,6 +416,9 @@ Zope Changes
...
@@ -416,6 +416,9 @@ Zope Changes
if( isinstance(status, types.ClassType) and issubclass(status, Exception))
if( isinstance(status, types.ClassType) and issubclass(status, Exception))
to if( isinstance(status, (type, types.ClassType)) and issubclass(status, Exception))
to if( isinstance(status, (type, types.ClassType)) and issubclass(status, Exception))
for fixing the failures in the module Zope2
for fixing the failures in the module Zope2
- The Wrapper_compare function from tp_compare to tp_richcompare.
Also another function Wrapper_richcompare is added.
Other Changes
Other Changes
...
...
lib/python/Acquisition/_Acquisition.c
View file @
f6669501
...
@@ -103,6 +103,32 @@ CallMethodO(PyObject *self, PyObject *name,
...
@@ -103,6 +103,32 @@ CallMethodO(PyObject *self, PyObject *name,
#define Build Py_BuildValue
#define Build Py_BuildValue
/* For obscure reasons, we need to use tp_richcompare instead of tp_compare.
* The comparisons here all most naturally compute a cmp()-like result.
* This little helper turns that into a bool result for rich comparisons.
*/
static
PyObject
*
diff_to_bool
(
int
diff
,
int
op
)
{
PyObject
*
result
;
int
istrue
;
switch
(
op
)
{
case
Py_EQ
:
istrue
=
diff
==
0
;
break
;
case
Py_NE
:
istrue
=
diff
!=
0
;
break
;
case
Py_LE
:
istrue
=
diff
<=
0
;
break
;
case
Py_GE
:
istrue
=
diff
>=
0
;
break
;
case
Py_LT
:
istrue
=
diff
<
0
;
break
;
case
Py_GT
:
istrue
=
diff
>
0
;
break
;
default:
assert
(
!
"op unknown"
);
istrue
=
0
;
/* To shut up compiler */
}
result
=
istrue
?
Py_True
:
Py_False
;
Py_INCREF
(
result
);
return
result
;
}
/* Declarations for objects of type Wrapper */
/* Declarations for objects of type Wrapper */
typedef
struct
{
typedef
struct
{
...
@@ -758,6 +784,13 @@ Wrapper_compare(Wrapper *self, PyObject *w)
...
@@ -758,6 +784,13 @@ Wrapper_compare(Wrapper *self, PyObject *w)
return
r
;
return
r
;
}
}
static
PyObject
*
Wrapper_richcompare
(
Wrapper
*
self
,
PyObject
*
w
,
int
op
)
{
int
diff
=
Wrapper_compare
(
self
,
w
);
return
diff_to_bool
(
diff
,
op
);
}
static
PyObject
*
static
PyObject
*
Wrapper_repr
(
Wrapper
*
self
)
Wrapper_repr
(
Wrapper
*
self
)
{
{
...
@@ -1241,7 +1274,7 @@ static PyExtensionClass Wrappertype = {
...
@@ -1241,7 +1274,7 @@ static PyExtensionClass Wrappertype = {
(
printfunc
)
0
,
/*tp_print*/
(
printfunc
)
0
,
/*tp_print*/
(
getattrfunc
)
0
,
/*tp_getattr*/
(
getattrfunc
)
0
,
/*tp_getattr*/
(
setattrfunc
)
0
,
/*tp_setattr*/
(
setattrfunc
)
0
,
/*tp_setattr*/
(
cmpfunc
)
Wrapper_compare
,
/*tp_compare*/
(
cmpfunc
)
0
,
/*tp_compare*/
(
reprfunc
)
Wrapper_repr
,
/*tp_repr*/
(
reprfunc
)
Wrapper_repr
,
/*tp_repr*/
&
Wrapper_as_number
,
/*tp_as_number*/
&
Wrapper_as_number
,
/*tp_as_number*/
&
Wrapper_as_sequence
,
/*tp_as_sequence*/
&
Wrapper_as_sequence
,
/*tp_as_sequence*/
...
@@ -1259,7 +1292,7 @@ static PyExtensionClass Wrappertype = {
...
@@ -1259,7 +1292,7 @@ static PyExtensionClass Wrappertype = {
"Wrapper object for implicit acquisition"
,
/* Documentation string */
"Wrapper object for implicit acquisition"
,
/* Documentation string */
/* tp_traverse */
(
traverseproc
)
Wrapper_traverse
,
/* tp_traverse */
(
traverseproc
)
Wrapper_traverse
,
/* tp_clear */
(
inquiry
)
Wrapper_clear
,
/* tp_clear */
(
inquiry
)
Wrapper_clear
,
/* tp_richcompare */
(
richcmpfunc
)
0
,
/* tp_richcompare */
(
richcmpfunc
)
Wrapper_richcompare
,
/* tp_weaklistoffset */
(
long
)
0
,
/* tp_weaklistoffset */
(
long
)
0
,
/* tp_iter */
(
getiterfunc
)
0
,
/* tp_iter */
(
getiterfunc
)
0
,
/* tp_iternext */
(
iternextfunc
)
0
,
/* tp_iternext */
(
iternextfunc
)
0
,
...
...
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