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
53d76dcf
Commit
53d76dcf
authored
Sep 29, 2000
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Fix acquisition wrapper comparisons (Collector #1650)
parent
4aedef26
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
8 deletions
+57
-8
doc/CHANGES.txt
doc/CHANGES.txt
+7
-0
lib/Components/ExtensionClass/Acquisition.c
lib/Components/ExtensionClass/Acquisition.c
+19
-4
lib/Components/ExtensionClass/src/Acquisition.c
lib/Components/ExtensionClass/src/Acquisition.c
+19
-4
lib/Components/ExtensionClass/test/test_acquisition.py
lib/Components/ExtensionClass/test/test_acquisition.py
+12
-0
No files found.
doc/CHANGES.txt
View file @
53d76dcf
...
...
@@ -30,3 +30,10 @@ Zope changes
return the right thing regardless of how the id of the
object is stored internally.
Bugs Fixed
- (Collector #1650)Where the underlying object does not define
its own '__cmp__()', comparisons of acquisition-wrapped
objects fall back to comparing the identities *of the
wrappers* . Fixed to unrwap the object (both, if needed)
before comparing identities.
lib/Components/ExtensionClass/Acquisition.c
View file @
53d76dcf
...
...
@@ -33,7 +33,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
$Id: Acquisition.c,v 1.4
3 2000/09/29 15:44:53 shane
Exp $
$Id: Acquisition.c,v 1.4
4 2000/09/29 17:21:27 tseaver
Exp $
If you have questions regarding this software,
contact:
...
...
@@ -605,6 +605,7 @@ Wrapper_setattro(Wrapper *self, PyObject *oname, PyObject *v)
static
int
Wrapper_compare
(
Wrapper
*
self
,
PyObject
*
w
)
{
PyObject
*
obj
,
*
wobj
;
PyObject
*
m
;
int
r
;
...
...
@@ -612,8 +613,22 @@ Wrapper_compare(Wrapper *self, PyObject *w)
UNLESS
(
m
=
PyObject_GetAttr
(
OBJECT
(
self
),
py__cmp__
))
{
/* Unwrap self completely -> obj. */
while
(
self
->
obj
&&
isWrapper
(
self
->
obj
))
self
=
WRAPPER
(
self
->
obj
);
obj
=
self
->
obj
;
/* Unwrap w completely -> wobj. */
if
(
isWrapper
(
w
))
{
while
(
WRAPPER
(
w
)
->
obj
&&
isWrapper
(
WRAPPER
(
w
)
->
obj
))
w
=
WRAPPER
(
w
)
->
obj
;
wobj
=
WRAPPER
(
w
)
->
obj
;
}
else
wobj
=
w
;
PyErr_Clear
();
return
(
OBJECT
(
self
)
<
w
)
?
-
1
:
1
;
if
(
obj
==
wobj
)
return
0
;
return
(
obj
<
w
)
?
-
1
:
1
;
}
ASSIGN
(
m
,
PyObject_CallFunction
(
m
,
"O"
,
w
));
...
...
@@ -1401,7 +1416,7 @@ void
initAcquisition
()
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.4
3
$"
;
char
*
rev
=
"$Revision: 1.4
4
$"
;
PURE_MIXIN_CLASS
(
Acquirer
,
"Base class for objects that implicitly"
" acquire attributes from containers
\n
"
...
...
@@ -1420,7 +1435,7 @@ initAcquisition()
/* Create the module and add the functions */
m
=
Py_InitModule4
(
"Acquisition"
,
methods
,
"Provide base classes for acquiring objects
\n\n
"
"$Id: Acquisition.c,v 1.4
3 2000/09/29 15:44:53 shane
Exp $
\n
"
,
"$Id: Acquisition.c,v 1.4
4 2000/09/29 17:21:27 tseaver
Exp $
\n
"
,
OBJECT
(
NULL
),
PYTHON_API_VERSION
);
d
=
PyModule_GetDict
(
m
);
...
...
lib/Components/ExtensionClass/src/Acquisition.c
View file @
53d76dcf
...
...
@@ -33,7 +33,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
$Id: Acquisition.c,v 1.4
3 2000/09/29 15:44:53 shane
Exp $
$Id: Acquisition.c,v 1.4
4 2000/09/29 17:21:27 tseaver
Exp $
If you have questions regarding this software,
contact:
...
...
@@ -605,6 +605,7 @@ Wrapper_setattro(Wrapper *self, PyObject *oname, PyObject *v)
static
int
Wrapper_compare
(
Wrapper
*
self
,
PyObject
*
w
)
{
PyObject
*
obj
,
*
wobj
;
PyObject
*
m
;
int
r
;
...
...
@@ -612,8 +613,22 @@ Wrapper_compare(Wrapper *self, PyObject *w)
UNLESS
(
m
=
PyObject_GetAttr
(
OBJECT
(
self
),
py__cmp__
))
{
/* Unwrap self completely -> obj. */
while
(
self
->
obj
&&
isWrapper
(
self
->
obj
))
self
=
WRAPPER
(
self
->
obj
);
obj
=
self
->
obj
;
/* Unwrap w completely -> wobj. */
if
(
isWrapper
(
w
))
{
while
(
WRAPPER
(
w
)
->
obj
&&
isWrapper
(
WRAPPER
(
w
)
->
obj
))
w
=
WRAPPER
(
w
)
->
obj
;
wobj
=
WRAPPER
(
w
)
->
obj
;
}
else
wobj
=
w
;
PyErr_Clear
();
return
(
OBJECT
(
self
)
<
w
)
?
-
1
:
1
;
if
(
obj
==
wobj
)
return
0
;
return
(
obj
<
w
)
?
-
1
:
1
;
}
ASSIGN
(
m
,
PyObject_CallFunction
(
m
,
"O"
,
w
));
...
...
@@ -1401,7 +1416,7 @@ void
initAcquisition
()
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.4
3
$"
;
char
*
rev
=
"$Revision: 1.4
4
$"
;
PURE_MIXIN_CLASS
(
Acquirer
,
"Base class for objects that implicitly"
" acquire attributes from containers
\n
"
...
...
@@ -1420,7 +1435,7 @@ initAcquisition()
/* Create the module and add the functions */
m
=
Py_InitModule4
(
"Acquisition"
,
methods
,
"Provide base classes for acquiring objects
\n\n
"
"$Id: Acquisition.c,v 1.4
3 2000/09/29 15:44:53 shane
Exp $
\n
"
,
"$Id: Acquisition.c,v 1.4
4 2000/09/29 17:21:27 tseaver
Exp $
\n
"
,
OBJECT
(
NULL
),
PYTHON_API_VERSION
);
d
=
PyModule_GetDict
(
m
);
...
...
lib/Components/ExtensionClass/test/test_acquisition.py
View file @
53d76dcf
...
...
@@ -17,3 +17,15 @@ try:
raise
'Program error'
,
'spam'
except
AttributeError
:
pass
#
# New test for wrapper comparisons.
#
foo
=
b
.
a
bar
=
b
.
a
assert
(
foo
==
bar
)
c
=
A
()
b
.
c
=
c
b
.
c
.
d
=
c
assert
(
b
.
c
.
d
==
c
)
assert
(
b
.
c
.
d
==
b
.
c
)
assert
(
b
.
c
==
c
)
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