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
640a36ca
Commit
640a36ca
authored
May 09, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Real fix for the coercion problem.
parent
fbb7ba2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
lib/Components/ExtensionClass/src/Missing.c
lib/Components/ExtensionClass/src/Missing.c
+18
-6
No files found.
lib/Components/ExtensionClass/src/Missing.c
View file @
640a36ca
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
static
char
Missing_module_documentation
[]
=
static
char
Missing_module_documentation
[]
=
""
""
"
\n
$Id: Missing.c,v 1.1
8 2003/05/09 19:59:31
jeremy Exp $"
"
\n
$Id: Missing.c,v 1.1
9 2003/05/09 20:57:10
jeremy Exp $"
;
;
#include "ExtensionClass.h"
#include "ExtensionClass.h"
...
@@ -78,14 +78,19 @@ Missing_nonzero(PyObject *v)
...
@@ -78,14 +78,19 @@ Missing_nonzero(PyObject *v)
return
0
;
return
0
;
}
}
/* XXX Why does this type offer to corece at all? */
/* coerce should return two values of the same type.
We violate that contract in a controlled way, by always coercing
the other object to Py_None. We are guaranteed that our tp_compare
will be called because Py_None does not define a tp_compare.
*/
static
int
static
int
Missing_coerce
(
PyObject
**
pv
,
PyObject
**
pw
)
Missing_coerce
(
PyObject
**
pv
,
PyObject
**
pw
)
{
{
if
(
!
(
*
pw
)
->
ob_type
->
tp_as_number
)
return
1
;
Py_INCREF
(
*
pv
);
Py_INCREF
(
*
pv
);
Py_INCREF
(
*
pw
);
Py_INCREF
(
Py_None
);
*
pw
=
Py_None
;
return
0
;
return
0
;
}
}
...
@@ -221,10 +226,16 @@ Missing_call(PyObject *self, PyObject *args, PyObject *kw)
...
@@ -221,10 +226,16 @@ Missing_call(PyObject *self, PyObject *args, PyObject *kw)
return
self
;
return
self
;
}
}
/* All Missing objects are equal to each other, but we have
specially arranged for Py_None to be passed as m2 via
Missing_coerce(). So be prepared for Py_None where
a Missing is expected.
*/
static
int
static
int
Missing_cmp
(
Missing
*
m1
,
Missing
*
m2
)
Missing_cmp
(
Missing
*
m1
,
Missing
*
m2
)
{
{
return
m1
->
ob_type
!=
m2
->
ob_type
;
return
Py_None
==
(
PyObject
*
)
m2
;
}
}
static
PyExtensionClass
MissingType
=
{
static
PyExtensionClass
MissingType
=
{
...
@@ -296,3 +307,4 @@ initMissing(void)
...
@@ -296,3 +307,4 @@ initMissing(void)
PyDict_SetItemString
(
d
,
"V"
,
theValue
);
PyDict_SetItemString
(
d
,
"V"
,
theValue
);
PyDict_SetItemString
(
d
,
"MV"
,
theValue
);
PyDict_SetItemString
(
d
,
"MV"
,
theValue
);
}
}
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