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
81a372d9
Commit
81a372d9
authored
Apr 18, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
7819995d
' into refcounting
Conflicts: src/runtime/float.cpp
parents
916a2dcf
7819995d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
53 deletions
+9
-53
src/runtime/float.cpp
src/runtime/float.cpp
+9
-53
No files found.
src/runtime/float.cpp
View file @
81a372d9
...
...
@@ -919,59 +919,15 @@ Box* floatNonzero(BoxedFloat* self) {
return
boxBool
(
floatNonzeroUnboxed
(
self
));
}
template
<
ExceptionStyle
S
>
static
BoxedFloat
*
_floatNew
(
Box
*
a
)
noexcept
(
S
==
CAPI
)
{
if
(
a
->
cls
==
float_cls
)
{
return
static_cast
<
BoxedFloat
*>
(
incref
(
a
));
}
else
if
(
PyInt_Check
(
a
))
{
return
new
BoxedFloat
(
static_cast
<
BoxedInt
*>
(
a
)
->
n
);
}
else
if
(
PyLong_Check
(
a
))
{
double
a_f
=
PyLong_AsDouble
(
a
);
if
(
a_f
==
-
1.0
&&
PyErr_Occurred
())
{
if
(
S
==
CAPI
)
return
NULL
;
else
throwCAPIException
();
}
// Make sure that we're not in an error state when we return a non-NULL value.
assert
(
!
PyErr_Occurred
());
return
new
BoxedFloat
(
a_f
);
}
else
if
(
a
->
cls
==
str_cls
||
a
->
cls
==
unicode_cls
)
{
BoxedFloat
*
res
=
(
BoxedFloat
*
)
PyFloat_FromString
(
a
,
NULL
);
if
(
!
res
)
{
if
(
S
==
CAPI
)
return
NULL
;
else
throwCAPIException
();
}
return
res
;
}
else
{
static
BoxedString
*
float_str
=
getStaticString
(
"__float__"
);
Box
*
r
=
callattrInternal
<
S
,
NOT_REWRITABLE
>
(
a
,
float_str
,
CLASS_ONLY
,
NULL
,
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
!
r
)
{
if
(
S
==
CAPI
)
{
if
(
!
PyErr_Occurred
())
PyErr_SetString
(
PyExc_TypeError
,
"float() argument must be a string or a number"
);
return
NULL
;
}
else
{
raiseExcHelper
(
TypeError
,
"float() argument must be a string or a number"
);
}
}
if
(
!
PyFloat_Check
(
r
))
{
if
(
S
==
CAPI
)
{
PyErr_Format
(
TypeError
,
"__float__ returned non-float (type %s)"
,
r
->
cls
->
tp_name
);
return
NULL
;
}
else
raiseExcHelper
(
TypeError
,
"__float__ returned non-float (type %s)"
,
r
->
cls
->
tp_name
);
}
return
static_cast
<
BoxedFloat
*>
(
r
);
}
template
<
ExceptionStyle
S
>
static
BoxedFloat
*
_floatNew
(
Box
*
x
)
noexcept
(
S
==
CAPI
)
{
Box
*
rtn
;
if
(
PyString_CheckExact
(
x
))
rtn
=
PyFloat_FromString
(
x
,
NULL
);
else
rtn
=
PyNumber_Float
(
x
);
if
(
!
rtn
&&
S
==
CXX
)
throwCAPIException
();
return
static_cast
<
BoxedFloat
*>
(
rtn
);
}
template
<
ExceptionStyle
S
>
Box
*
floatNew
(
BoxedClass
*
_cls
,
Box
*
a
)
noexcept
(
S
==
CAPI
)
{
...
...
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