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
2a3b70eb
Commit
2a3b70eb
authored
Apr 19, 2016
by
Boxiang Sun
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return NotImplemented in intXXXFloat for float subtypes
parent
94020486
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
+39
-7
src/runtime/int.cpp
src/runtime/int.cpp
+7
-7
test/tests/float.py
test/tests/float.py
+32
-0
No files found.
src/runtime/int.cpp
View file @
2a3b70eb
...
...
@@ -430,7 +430,7 @@ extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
add_i64_i64
(
lhs
->
n
,
rhs_int
->
n
);
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
boxFloat
(
lhs
->
n
+
rhs_float
->
d
);
}
else
{
...
...
@@ -559,7 +559,7 @@ extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
return
intDivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
return
intDivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
return
NotImplemented
;
...
...
@@ -601,7 +601,7 @@ extern "C" Box* intFloordiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
return
intFloordivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
return
intFloordivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
return
NotImplemented
;
...
...
@@ -647,7 +647,7 @@ extern "C" Box* intTruediv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
return
intTruedivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
return
intTruedivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
return
NotImplemented
;
...
...
@@ -790,7 +790,7 @@ extern "C" Box* intMul(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intMulInt
(
lhs
,
rhs_int
);
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
intMulFloat
(
lhs
,
rhs_float
);
}
else
{
...
...
@@ -842,7 +842,7 @@ extern "C" Box* intPow(BoxedInt* lhs, Box* rhs, Box* mod) {
if
(
PyLong_Check
(
rhs
))
return
intPowLong
(
lhs
,
static_cast
<
BoxedLong
*>
(
rhs
),
mod
);
else
if
(
PyFloat_Check
(
rhs
))
else
if
(
PyFloat_Check
Exact
(
rhs
))
return
intPowFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
),
mod
);
else
if
(
!
PyInt_Check
(
rhs
))
return
NotImplemented
;
...
...
@@ -937,7 +937,7 @@ extern "C" Box* intSub(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intSubInt
(
lhs
,
rhs_int
);
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
intSubFloat
(
lhs
,
rhs_float
);
}
else
{
...
...
test/tests/float.py
View file @
2a3b70eb
...
...
@@ -141,3 +141,35 @@ for x in data:
arg2
=
y
)))
except
Exception
as
e
:
print
(
e
.
message
)
class
Foo1
(
float
):
def
__rdiv__
(
self
,
other
):
print
(
"float custom operation called"
)
return
self
/
other
class
Foo2
(
long
):
def
__rdiv__
(
self
,
other
):
print
(
"long custom operation called"
)
return
self
/
other
class
Foo3
(
int
):
def
__rdiv__
(
self
,
other
):
print
(
"int custom operation called"
)
return
self
/
other
a
=
Foo1
(
1.5
)
b
=
Foo2
(
1L
)
c
=
Foo3
(
1
)
print
(
1.5
/
a
)
print
(
1.5
/
b
)
print
(
1.5
/
c
)
print
(
1
/
a
)
print
(
1
/
b
)
print
(
1
/
c
)
print
(
1L
/
a
)
print
(
1L
/
b
)
print
(
1L
/
c
)
Boxiang Sun
@Daetalus
mentioned in commit
916a2dcf
·
Sep 08, 2016
mentioned in commit
916a2dcf
mentioned in commit 916a2dcf564b8a02bfd207e88f06a04a26e48c81
Toggle commit list
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