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
1874cddc
Commit
1874cddc
authored
May 07, 2016
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
May 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another setAddStolen issue
This time it was if __eq__ throws.
parent
968cd670
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
8 deletions
+38
-8
from_cpython/Lib/test/test_set.py
from_cpython/Lib/test/test_set.py
+0
-2
src/runtime/dict.cpp
src/runtime/dict.cpp
+9
-3
src/runtime/set.cpp
src/runtime/set.cpp
+14
-3
test/tests/dict_internals.py
test/tests/dict_internals.py
+15
-0
No files found.
from_cpython/Lib/test/test_set.py
View file @
1874cddc
# expected: reffail
# - leaked refs
import
unittest
from
test
import
test_support
import
gc
...
...
src/runtime/dict.cpp
View file @
1874cddc
...
...
@@ -36,10 +36,16 @@ BoxedClass* dictiteritem_cls = NULL;
}
static
void
_dictSetStolen
(
BoxedDict
*
self
,
BoxAndHash
k
,
STOLEN
(
Box
*
)
v
)
{
Box
*&
slot
=
self
->
d
[
k
];
Box
*
old_val
=
slot
;
Box
**
slot
=
NULL
;
try
{
slot
=
&
self
->
d
[
k
];
}
catch
(
ExcInfo
e
)
{
Py_DECREF
(
v
);
throw
e
;
}
Box
*
old_val
=
*
slot
;
slot
=
v
;
*
slot
=
v
;
if
(
old_val
)
{
Py_DECREF
(
old_val
);
...
...
src/runtime/set.cpp
View file @
1874cddc
...
...
@@ -25,10 +25,21 @@ extern "C" Box* createSet() {
}
static
void
_setAddStolen
(
BoxedSet
*
self
,
STOLEN
(
BoxAndHash
)
val
)
{
auto
&&
p
=
self
->
s
.
insert
(
val
);
if
(
!
p
.
second
/* already exists */
)
{
// keep the original key
try
{
auto
&&
p
=
self
->
s
.
insert
(
val
);
// Is there a nicer way to represent try-else?
try
{
if
(
!
p
.
second
/* already exists */
)
{
// keep the original key
Py_DECREF
(
val
.
value
);
}
}
catch
(
ExcInfo
e
)
{
abort
();
}
}
catch
(
ExcInfo
e
)
{
Py_DECREF
(
val
.
value
);
throw
e
;
}
}
...
...
test/tests/dict_internals.py
View file @
1874cddc
...
...
@@ -55,3 +55,18 @@ d = {}
for
i
in
xrange
(
1000
):
d
[
C
(
i
)]
=
i
print
len
(
d
)
class
NonEq
(
object
):
def
__eq__
(
self
,
rhs
):
1
/
0
def
__hash__
(
self
):
return
0
d
=
{}
d
[
NonEq
()]
=
1
try
:
d
[
NonEq
()]
=
2
except
ZeroDivisionError
as
e
:
print
e
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