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
f0dd5232
Commit
f0dd5232
authored
Apr 08, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A bunch of small fixes
parent
605702a7
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
54 additions
and
21 deletions
+54
-21
src/capi/object.cpp
src/capi/object.cpp
+3
-0
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+3
-3
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+21
-6
src/runtime/int.cpp
src/runtime/int.cpp
+3
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-0
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
test/tests/generator_osr.py
test/tests/generator_osr.py
+0
-1
test/tests/intmethods.py
test/tests/intmethods.py
+3
-1
test/tests/intmethods_exceptions.py
test/tests/intmethods_exceptions.py
+14
-0
test/tests/itertools_test.py
test/tests/itertools_test.py
+0
-1
test/tests/mutable_bases.py
test/tests/mutable_bases.py
+0
-1
test/tests/object_reduce.py
test/tests/object_reduce.py
+0
-1
test/tests/optparse_test.py
test/tests/optparse_test.py
+0
-1
test/tests/os_test.py
test/tests/os_test.py
+0
-1
test/tests/reduce.py
test/tests/reduce.py
+5
-1
test/tests/reversed.py
test/tests/reversed.py
+0
-1
test/tests/setattr.py
test/tests/setattr.py
+0
-1
No files found.
src/capi/object.cpp
View file @
f0dd5232
...
...
@@ -490,7 +490,10 @@ extern "C" int PyObject_GenericSetAttr(PyObject* obj, PyObject* name, PyObject*
PyErr_Format
(
PyExc_TypeError
,
"attribute name must be string, not '%.200s'"
,
Py_TYPE
(
name
)
->
tp_name
);
return
-
1
;
}
}
else
{
Py_INCREF
(
name
);
}
AUTO_DECREF
(
name
);
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
name
);
incref
(
str
);
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
f0dd5232
...
...
@@ -853,14 +853,15 @@ Box* map(Box* f, BoxedTuple* args) {
}
Box
*
reduce
(
Box
*
f
,
Box
*
container
,
Box
*
initial
)
{
assert
(
0
&&
"check refcounting"
);
Box
*
current
=
initial
;
Box
*
current
=
xincref
(
initial
);
for
(
Box
*
e
:
container
->
pyElements
())
{
assert
(
e
);
if
(
current
==
NULL
)
{
current
=
e
;
}
else
{
AUTO_DECREF
(
current
);
AUTO_DECREF
(
e
);
current
=
runtimeCall
(
f
,
ArgPassSpec
(
2
),
current
,
e
,
NULL
,
NULL
,
NULL
);
}
}
...
...
@@ -1588,7 +1589,6 @@ static PyObject* builtin_reload(PyObject* self, PyObject* v) noexcept {
}
Box
*
getreversed
(
Box
*
o
)
{
assert
(
0
&&
"check refcounting"
);
static
BoxedString
*
reversed_str
=
getStaticString
(
"__reversed__"
);
// common case:
...
...
src/runtime/classobj.cpp
View file @
f0dd5232
...
...
@@ -1791,8 +1791,15 @@ int BoxedInstance::traverse(Box* o, visitproc visit, void* arg) noexcept {
return
0
;
}
int
BoxedInstance
::
clear
(
Box
*
self
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
int
BoxedInstance
::
clear
(
Box
*
o
)
noexcept
{
BoxedInstance
*
self
=
static_cast
<
BoxedInstance
*>
(
o
);
self
->
attrs
.
clearForDealloc
();
// I think it is ok to not clear this:
// Py_CLEAR(self->inst_cls);
return
0
;
}
void
BoxedClassobj
::
dealloc
(
Box
*
b
)
noexcept
{
...
...
@@ -1800,14 +1807,14 @@ void BoxedClassobj::dealloc(Box* b) noexcept {
BoxedClassobj
*
cl
=
static_cast
<
BoxedClassobj
*>
(
b
);
Py_DECREF
(
cl
->
bases
);
Py_DECREF
(
cl
->
name
);
if
(
cl
->
weakreflist
)
PyObject_ClearWeakRefs
(
cl
);
cl
->
clearAttrsForDealloc
();
Py_DECREF
(
cl
->
bases
);
Py_DECREF
(
cl
->
name
);
cl
->
cls
->
tp_free
(
cl
);
}
...
...
@@ -1821,7 +1828,15 @@ int BoxedClassobj::traverse(Box* o, visitproc visit, void* arg) noexcept {
}
int
BoxedClassobj
::
clear
(
Box
*
self
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
BoxedClassobj
*
cl
=
static_cast
<
BoxedClassobj
*>
(
self
);
cl
->
attrs
.
clearForDealloc
();
// I think it is ok to not clear these:
// Py_CLEAR(cl->bases);
// Py_CLEAR(cl->name);
return
0
;
}
void
setupClassobj
()
{
...
...
src/runtime/int.cpp
View file @
f0dd5232
...
...
@@ -940,7 +940,7 @@ Box* intRPow(BoxedInt* lhs, Box* rhs, Box* mod) {
}
Box
*
rtn
=
pow_i64_i64
(
rhs_int
->
n
,
lhs
->
n
,
mod
);
if
(
PyLong_Check
(
rtn
))
return
longInt
(
rtn
);
return
longInt
(
autoDecref
(
rtn
)
);
return
rtn
;
}
...
...
@@ -1304,6 +1304,8 @@ template <ExceptionStyle S> Box* intNew(Box* _cls, Box* val, Box* base) noexcept
if
(
cls
==
int_cls
)
return
n
;
Py_DECREF
(
n
);
if
(
S
==
CAPI
)
{
PyErr_SetString
(
OverflowError
,
"Python int too large to convert to C long"
);
return
NULL
;
...
...
src/runtime/objmodel.cpp
View file @
f0dd5232
...
...
@@ -3610,6 +3610,7 @@ extern "C" i64 unboxedLen(Box* obj) {
assert
(
lobj
->
cls
==
int_cls
);
i64
rtn
=
lobj
->
n
;
Py_DECREF
(
lobj
);
if
(
rewriter
.
get
())
{
assert
(
0
&&
"how do we know this will return an int?"
);
...
...
src/runtime/types.cpp
View file @
f0dd5232
...
...
@@ -3054,7 +3054,7 @@ static PyObject* import_copyreg(void) noexcept {
if
(
!
copyreg_str
)
{
// this is interned in cpython:
copyreg_str
=
PyString_From
String
(
"copy_reg"
);
copyreg_str
=
getStatic
String
(
"copy_reg"
);
if
(
copyreg_str
==
NULL
)
return
NULL
;
}
...
...
test/tests/generator_osr.py
View file @
f0dd5232
# expected: reffail
# This test could really benefit from defined/settable OSR limits
def
f
(
x
):
...
...
test/tests/intmethods.py
View file @
f0dd5232
# expected: reffail
# can't try large numbers yet due to lack of long
for
i
in
xrange
(
1
,
100
):
for
j
in
xrange
(
1
,
100
):
...
...
@@ -83,6 +82,8 @@ print int("0b101", 2), int("0b101", 0)
print
1
<<
63
,
1
<<
64
,
-
1
<<
63
,
-
1
<<
64
,
2
<<
63
print
type
(
1
<<
63
),
type
(
1
<<
64
),
type
(
-
1
<<
63
),
type
(
-
1
<<
64
),
type
(
2
<<
63
)
# TODO: enable this once intmethods_exceptions is working
'''
for b in range(26):
try:
print int('123', b)
...
...
@@ -92,6 +93,7 @@ for b in range(26):
print int(u'123', b)
except ValueError as e:
print e
'''
class
I
(
int
):
...
...
test/tests/intmethods_exceptions.py
0 → 100644
View file @
f0dd5232
# expected: reffail
# - throws exceptions out of ICs
# TODO: move this back to intmethods.py once this is working
for
b
in
range
(
26
):
try
:
print
int
(
'123'
,
b
)
except
ValueError
as
e
:
print
e
try
:
print
int
(
u'123'
,
b
)
except
ValueError
as
e
:
print
e
test/tests/itertools_test.py
View file @
f0dd5232
# expected: reffail
import
itertools
its
=
[]
...
...
test/tests/mutable_bases.py
View file @
f0dd5232
# expected: reffail
class
A
(
object
):
def
foo
(
self
):
print
"foo"
...
...
test/tests/object_reduce.py
View file @
f0dd5232
# expected: reffail
o
=
object
()
r
=
o
.
__reduce__
()
print
type
(
r
),
len
(
r
)
...
...
test/tests/optparse_test.py
View file @
f0dd5232
# expected: reffail
# Simple optparse test, taken from the optparse.py docstring:
from
optparse
import
OptionParser
...
...
test/tests/os_test.py
View file @
f0dd5232
# expected: reffail
#
# currently broken:
...
...
test/tests/reduce.py
View file @
f0dd5232
# expected: reffail
import
operator
print
reduce
(
operator
.
add
,
range
(
50
))
...
...
@@ -23,3 +22,8 @@ try:
print
reduce
(
f
,
[])
except
TypeError
,
e
:
print
e
try
:
print
reduce
(
lambda
x
,
y
:
x
/
y
,
range
(
-
10
,
10
))
except
Exception
as
e
:
print
e
test/tests/reversed.py
View file @
f0dd5232
# expected: reffail
print
list
(
reversed
(
"hello"
))
print
list
(
reversed
(
""
))
...
...
test/tests/setattr.py
View file @
f0dd5232
# expected: reffail
class
MyDescr
(
object
):
def
__set__
(
self
,
inst
,
val
):
print
type
(
self
),
type
(
inst
),
val
...
...
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