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
fbff808d
Commit
fbff808d
authored
Nov 19, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refcounting fixes
parent
8bf40b6d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
4 deletions
+25
-4
src/runtime/capi.cpp
src/runtime/capi.cpp
+5
-0
src/runtime/list.cpp
src/runtime/list.cpp
+15
-3
src/runtime/types.cpp
src/runtime/types.cpp
+2
-1
src/runtime/types.h
src/runtime/types.h
+3
-0
No files found.
src/runtime/capi.cpp
View file @
fbff808d
...
...
@@ -1470,6 +1470,11 @@ extern "C" PyObject* PyThreadState_GetDict(void) noexcept {
return
dict
;
}
extern
"C"
void
PyThreadState_Clear
(
PyThreadState
*
tstate
)
noexcept
{
assert
(
tstate
==
NULL
);
Py_CLEAR
(
cur_thread_state
.
dict
);
}
extern
"C"
int
_PyOS_URandom
(
void
*
buffer
,
Py_ssize_t
size
)
noexcept
{
if
(
size
<
0
)
{
PyErr_Format
(
PyExc_ValueError
,
"negative argument not allowed"
);
...
...
src/runtime/list.cpp
View file @
fbff808d
...
...
@@ -87,6 +87,7 @@ extern "C" Box* listRepr(BoxedList* self) {
assert
(
r
->
cls
==
str_cls
);
BoxedString
*
s
=
static_cast
<
BoxedString
*>
(
r
);
chars
.
insert
(
chars
.
end
(),
s
->
s
().
begin
(),
s
->
s
().
end
());
Py_DECREF
(
s
);
}
chars
.
push_back
(
']'
);
}
catch
(
ExcInfo
e
)
{
...
...
@@ -542,13 +543,21 @@ static inline void listSetitemSliceInt64(BoxedList* self, i64 start, i64 stop, i
int
remaining_elts
=
self
->
size
-
stop
;
self
->
ensure
(
delts
);
// XXX should make a copy here in case a destructor gets run
for
(
int
i
=
start
;
i
<
step
;
i
++
)
{
Py_CLEAR
(
self
->
elts
->
elts
[
i
]);
}
memmove
(
self
->
elts
->
elts
+
start
+
v_size
,
self
->
elts
->
elts
+
stop
,
remaining_elts
*
sizeof
(
Box
*
));
for
(
int
i
=
0
;
i
<
v_size
;
i
++
)
{
Box
*
r
=
v_elts
[
i
];
Py_INCREF
(
r
);
self
->
elts
->
elts
[
start
+
i
]
=
r
;
}
self
->
size
+=
delts
;
Py_XDECREF
(
v_as_seq
);
}
extern
"C"
Box
*
listSetitemSlice
(
BoxedList
*
self
,
BoxedSlice
*
slice
,
Box
*
v
)
{
...
...
@@ -1246,12 +1255,15 @@ extern "C" int PyList_SetSlice(PyObject* a, Py_ssize_t ilow, Py_ssize_t ihigh, P
BoxedList
*
l
=
(
BoxedList
*
)
a
;
ASSERT
(
PyList_Check
(
l
),
"%s"
,
l
->
cls
->
tp_name
);
// TODO should just call list_ass_slice
try
{
BoxedSlice
*
slice
=
(
BoxedSlice
*
)
createSlice
(
boxInt
(
ilow
),
boxInt
(
ihigh
),
None
);
BoxedSlice
*
slice
=
(
BoxedSlice
*
)
createSlice
(
autoDecref
(
boxInt
(
ilow
)),
autoDecref
(
boxInt
(
ihigh
)
),
None
);
if
(
v
)
listSetitemSlice
(
l
,
slice
,
v
);
autoDecref
(
listSetitemSlice
(
l
,
slice
,
v
)
);
else
listDelitemSlice
(
l
,
slice
);
autoDecref
(
listDelitemSlice
(
l
,
slice
));
Py_DECREF
(
slice
);
return
0
;
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
...
...
src/runtime/types.cpp
View file @
fbff808d
...
...
@@ -262,7 +262,7 @@ BoxedString* Box::reprICAsString() {
Box
*
r
=
this
->
reprIC
();
if
(
isSubclass
(
r
->
cls
,
unicode_cls
))
{
r
=
PyUnicode_AsASCIIString
(
r
);
r
=
PyUnicode_AsASCIIString
(
autoDecref
(
r
)
);
checkAndThrowCAPIException
();
}
if
(
r
->
cls
!=
str_cls
)
{
...
...
@@ -4334,6 +4334,7 @@ extern "C" void Py_Finalize() noexcept {
PyOS_FiniInterrupts
();
PyType_ClearCache
();
_PyUnicode_Fini
();
PyThreadState_Clear
(
NULL
);
for
(
auto
b
:
constants
)
{
Py_DECREF
(
b
);
}
...
...
src/runtime/types.h
View file @
fbff808d
...
...
@@ -983,6 +983,9 @@ class BoxedSlice : public Box {
public:
Box
*
start
,
*
stop
,
*
step
;
BoxedSlice
(
Box
*
lower
,
Box
*
upper
,
Box
*
step
)
:
start
(
lower
),
stop
(
upper
),
step
(
step
)
{
Py_INCREF
(
lower
);
Py_INCREF
(
upper
);
Py_INCREF
(
step
);
ASSERT
(
lower
->
cls
==
none_cls
||
lower
->
cls
==
int_cls
,
"slice objects are not gc-aware (like in CPython)"
);
ASSERT
(
upper
->
cls
==
none_cls
||
upper
->
cls
==
int_cls
,
"slice objects are not gc-aware (like in CPython)"
);
ASSERT
(
step
->
cls
==
none_cls
||
step
->
cls
==
int_cls
,
"slice objects are not gc-aware (like in CPython)"
);
...
...
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