Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f5243f07
Commit
f5243f07
authored
Jan 01, 2008
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge changes from 59576 from trunk to p3yk branch; these were skipped
in the regular merge. Fixes issue #1693.
parent
a9de06d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
Objects/typeobject.c
Objects/typeobject.c
+16
-13
No files found.
Objects/typeobject.c
View file @
f5243f07
...
...
@@ -3167,28 +3167,22 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
type
->
tp_flags
|=
Py_TPFLAGS_DICT_SUBCLASS
;
}
/* Map rich comparison operators to their __xx__ namesakes */
static
char
*
name_op
[]
=
{
"__lt__"
,
"__le__"
,
static
char
*
hash_name_op
[]
=
{
"__eq__"
,
"__ne__"
,
"__gt__"
,
"__ge__"
,
/* These are only for overrides_cmp_or_hash(): */
"__cmp__"
,
"__hash__"
,
NULL
};
static
int
overrides_
cmp_or_
hash
(
PyTypeObject
*
type
)
overrides_hash
(
PyTypeObject
*
type
)
{
int
i
;
char
**
p
;
PyObject
*
dict
=
type
->
tp_dict
;
assert
(
dict
!=
NULL
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
PyDict_GetItemString
(
dict
,
name_op
[
i
]
)
!=
NULL
)
for
(
p
=
hash_name_op
;
*
p
;
p
++
)
{
if
(
PyDict_GetItemString
(
dict
,
*
p
)
!=
NULL
)
return
1
;
}
return
0
;
...
...
@@ -3314,7 +3308,7 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
if
(
type
->
tp_compare
==
NULL
&&
type
->
tp_richcompare
==
NULL
&&
type
->
tp_hash
==
NULL
&&
!
overrides_
cmp_or_
hash
(
type
))
!
overrides_hash
(
type
))
{
type
->
tp_compare
=
base
->
tp_compare
;
type
->
tp_richcompare
=
base
->
tp_richcompare
;
...
...
@@ -4739,6 +4733,15 @@ slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value)
return
0
;
}
static
char
*
name_op
[]
=
{
"__lt__"
,
"__le__"
,
"__eq__"
,
"__ne__"
,
"__gt__"
,
"__ge__"
,
};
static
PyObject
*
half_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
{
...
...
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