Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
3d34fe74
Commit
3d34fe74
authored
Jun 27, 2016
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
Jun 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 3-way-compare behavior on our old compareInternal() path
CPython has quite a bit more logic than just 'try __cmp__'
parent
01c34d81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
31 deletions
+6
-31
src/capi/object.cpp
src/capi/object.cpp
+1
-1
src/capi/types.h
src/capi/types.h
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+4
-30
No files found.
src/capi/object.cpp
View file @
3d34fe74
...
...
@@ -1004,7 +1004,7 @@ extern "C" int PyObject_Compare(PyObject* v, PyObject* w) noexcept {
Py_True if v op w
Py_False if not (v op w)
*/
static
PyObject
*
try_3way_to_rich_compare
(
PyObject
*
v
,
PyObject
*
w
,
int
op
)
noexcept
{
/* static */
PyObject
*
try_3way_to_rich_compare
(
PyObject
*
v
,
PyObject
*
w
,
int
op
)
noexcept
{
int
c
;
c
=
try_3way_compare
(
v
,
w
);
...
...
src/capi/types.h
View file @
3d34fe74
...
...
@@ -100,6 +100,7 @@ static_assert(offsetof(BoxedCApiFunction, method_def) == offsetof(PyCFunctionObj
static_assert
(
offsetof
(
BoxedCApiFunction
,
passthrough
)
==
offsetof
(
PyCFunctionObject
,
m_self
),
""
);
static_assert
(
offsetof
(
BoxedCApiFunction
,
module
)
==
offsetof
(
PyCFunctionObject
,
m_module
),
""
);
PyObject
*
try_3way_to_rich_compare
(
PyObject
*
v
,
PyObject
*
w
,
int
op
)
noexcept
;
PyObject
*
convert_3way_to_object
(
int
op
,
int
c
)
noexcept
;
int
default_3way_compare
(
PyObject
*
v
,
PyObject
*
w
);
...
...
src/runtime/objmodel.cpp
View file @
3d34fe74
...
...
@@ -5963,36 +5963,10 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
return
rrtn
;
Py_XDECREF
(
rrtn
);
// in case it is NotImplemented
static
BoxedString
*
cmp_str
=
getStaticString
(
"__cmp__"
);
lrtn
=
callattrInternal1
<
CXX
,
NOT_REWRITABLE
>
(
lhs
,
cmp_str
,
CLASS_ONLY
,
NULL
,
ArgPassSpec
(
1
),
rhs
);
AUTO_XDECREF
(
lrtn
);
if
(
lrtn
&&
lrtn
!=
NotImplemented
)
{
return
boxBool
(
convert3wayCompareResultToBool
(
lrtn
,
op_type
));
}
rrtn
=
callattrInternal1
<
CXX
,
NOT_REWRITABLE
>
(
rhs
,
cmp_str
,
CLASS_ONLY
,
NULL
,
ArgPassSpec
(
1
),
lhs
);
AUTO_XDECREF
(
rrtn
);
if
(
rrtn
&&
rrtn
!=
NotImplemented
)
{
bool
success
=
false
;
int
reversed_op
=
getReverseCmpOp
(
op_type
,
success
);
assert
(
success
);
return
boxBool
(
convert3wayCompareResultToBool
(
rrtn
,
reversed_op
));
}
if
(
op_type
==
AST_TYPE
::
Eq
)
return
boxBool
(
lhs
==
rhs
);
if
(
op_type
==
AST_TYPE
::
NotEq
)
return
boxBool
(
lhs
!=
rhs
);
#ifndef NDEBUG
if
((
lhs
->
cls
==
int_cls
||
lhs
->
cls
==
float_cls
||
lhs
->
cls
==
long_cls
)
&&
(
rhs
->
cls
==
int_cls
||
rhs
->
cls
==
float_cls
||
rhs
->
cls
==
long_cls
))
{
fprintf
(
stderr
,
"
\n
%s %s %s
\n
"
,
lhs
->
cls
->
tp_name
,
op_name
->
c_str
(),
rhs
->
cls
->
tp_name
);
Py_FatalError
(
"missing comparison between these classes"
);
}
#endif
int
c
=
default_3way_compare
(
lhs
,
rhs
);
return
convert_3way_to_object
(
cpython_op_type
,
c
);
Box
*
r
=
try_3way_to_rich_compare
(
lhs
,
rhs
,
cpython_op_type
);
if
(
!
r
)
throwCAPIException
();
return
r
;
}
extern
"C"
Box
*
compare
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
)
{
...
...
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