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
092351e9
Commit
092351e9
authored
Mar 29, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some ref fixes to complex
parent
7e42a198
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
7 deletions
+9
-7
from_cpython/Modules/cPickle.c
from_cpython/Modules/cPickle.c
+1
-1
from_cpython/Objects/complexobject.c
from_cpython/Objects/complexobject.c
+1
-0
src/runtime/complex.cpp
src/runtime/complex.cpp
+4
-4
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+3
-1
test/tests/complex.py
test/tests/complex.py
+0
-1
No files found.
from_cpython/Modules/cPickle.c
View file @
092351e9
...
...
@@ -5932,7 +5932,7 @@ init_stuff(PyObject *module_dict)
{
PyObject
*
copyreg
,
*
t
,
*
r
;
#define INIT_STR(S) if (!( S ## _str=Py
String_InternFromString(#S
))) return -1;
#define INIT_STR(S) if (!( S ## _str=Py
GC_RegisterStaticConstant(PyString_InternFromString(#S)
))) return -1;
if
(
PyType_Ready
(
&
Unpicklertype
)
<
0
)
return
-
1
;
...
...
from_cpython/Objects/complexobject.c
View file @
092351e9
...
...
@@ -289,6 +289,7 @@ try_complex_special_method(PyObject *op) {
complexstr
=
PyString_InternFromString
(
"__complex__"
);
if
(
complexstr
==
NULL
)
return
NULL
;
PyGC_RegisterStaticConstant
(
complexstr
);
}
if
(
PyInstance_Check
(
op
))
{
f
=
PyObject_GetAttr
(
op
,
complexstr
);
...
...
src/runtime/complex.cpp
View file @
092351e9
...
...
@@ -37,7 +37,7 @@ static Box* toComplex(Box* self) noexcept {
}
if
(
PyComplex_Check
(
self
))
{
r
=
(
BoxedComplex
*
)
self
;
r
=
(
BoxedComplex
*
)
incref
(
self
)
;
}
else
if
(
PyInt_Check
(
self
))
{
r
=
new
BoxedComplex
(
static_cast
<
BoxedInt
*>
(
self
)
->
n
,
0.0
);
}
else
if
(
PyFloat_Check
(
self
))
{
...
...
@@ -285,7 +285,7 @@ Box* complexTruediv(BoxedComplex* lhs, Box* rhs) {
double
res
=
PyLong_AsDouble
(
rhs
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
throwCAPIException
();
return
complexDivFloat
(
lhs
,
(
BoxedFloat
*
)
boxFloat
(
res
));
return
complexDivFloat
(
lhs
,
(
BoxedFloat
*
)
autoDecref
(
boxFloat
(
res
)
));
}
else
{
return
incref
(
NotImplemented
);
}
...
...
@@ -517,7 +517,7 @@ Box* complexDivmodComplex(BoxedComplex* lhs, Box* _rhs) {
AUTO_DECREF
(
div
);
div
->
real
=
floor
(
div
->
real
);
/* Use the floor of the real part. */
div
->
imag
=
0.0
;
BoxedComplex
*
mod
=
(
BoxedComplex
*
)
complexSubComplex
(
lhs
,
(
BoxedComplex
*
)
complexMulComplex
(
rhs_complex
,
div
));
BoxedComplex
*
mod
=
(
BoxedComplex
*
)
complexSubComplex
(
lhs
,
(
BoxedComplex
*
)
autoDecref
(
complexMulComplex
(
rhs_complex
,
div
)
));
AUTO_DECREF
(
mod
);
Box
*
res
=
BoxedTuple
::
create
({
div
,
mod
});
return
res
;
...
...
@@ -574,7 +574,7 @@ Box* complexModComplex(BoxedComplex* lhs, Box* _rhs) {
AUTO_DECREF
(
div
);
div
->
real
=
floor
(
div
->
real
);
/* Use the floor of the real part. */
div
->
imag
=
0.0
;
BoxedComplex
*
mod
=
(
BoxedComplex
*
)
complexSubComplex
(
lhs
,
(
BoxedComplex
*
)
complexMulComplex
(
rhs
,
div
));
BoxedComplex
*
mod
=
(
BoxedComplex
*
)
complexSubComplex
(
lhs
,
(
BoxedComplex
*
)
autoDecref
(
complexMulComplex
(
rhs
,
div
)
));
return
mod
;
}
...
...
src/runtime/objmodel.cpp
View file @
092351e9
...
...
@@ -1915,7 +1915,8 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedS
RewriterVar
::
SmallVector
normal_args
;
RewriterVar
::
SmallVector
float_args
;
float_args
.
push_back
(
r_unboxed_val
);
RewriterVar
*
r_rtn
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
boxFloat
,
normal_args
,
float_args
);
RewriterVar
*
r_rtn
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
boxFloat
,
normal_args
,
float_args
)
->
setType
(
RefType
::
OWNED
);
rewrite_args
->
setReturn
(
r_rtn
,
ReturnConvention
::
HAS_RETURN
);
}
...
...
@@ -7075,6 +7076,7 @@ extern "C" Box* boxedLocalsGet(Box* boxedLocals, BoxedString* attr, Box* globals
if
(
!
isSubclass
(
e
.
value
->
cls
,
KeyError
))
{
throw
e
;
}
e
.
clear
();
}
}
...
...
test/tests/complex.py
View file @
092351e9
# expected: reffail
# TODO repr is wrong, so for now, only printing complex numbers whose real
# and imaginary parts are non-integers
...
...
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