Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
85656957
Commit
85656957
authored
Jan 10, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix set.add(some_tuple) in Py2.4
parent
fc08e13d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
Cython/Utility/Builtins.c
Cython/Utility/Builtins.c
+2
-2
tests/run/set.pyx
tests/run/set.pyx
+9
-4
No files found.
Cython/Utility/Builtins.c
View file @
85656957
...
...
@@ -401,13 +401,13 @@ static CYTHON_INLINE int PySet_Clear(PyObject *set) {
}
static
CYTHON_INLINE
int
PySet_Discard
(
PyObject
*
set
,
PyObject
*
key
)
{
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"discard"
,
(
char
*
)
"
O
"
,
key
);
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"discard"
,
(
char
*
)
"
(O)
"
,
key
);
if
(
!
ret
)
return
-
1
;
Py_DECREF
(
ret
);
return
0
;
}
static
CYTHON_INLINE
int
PySet_Add
(
PyObject
*
set
,
PyObject
*
key
)
{
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"add"
,
(
char
*
)
"
O
"
,
key
);
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"add"
,
(
char
*
)
"
(O)
"
,
key
);
if
(
!
ret
)
return
-
1
;
Py_DECREF
(
ret
);
return
0
;
}
...
...
tests/run/set.pyx
View file @
85656957
...
...
@@ -35,13 +35,14 @@ def test_set_add():
>>> type(test_set_add()) is _set
True
>>> sorted(test_set_add())
['a', 1]
['a', 1
, (1, 2)
]
"""
cdef
set
s1
s1
=
set
([
1
])
s1
=
set
([
1
,
(
1
,
2
)
])
s1
.
add
(
1
)
s1
.
add
(
'a'
)
s1
.
add
(
1
)
s1
.
add
((
1
,
2
))
return
s1
def
test_set_clear
():
...
...
@@ -159,14 +160,18 @@ def test_set_of_tuple():
return
set
((
1
,
2
,
3
))
def
sorted
(
it
):
# Py3 can't compare
strings to int
s
# Py3 can't compare
different type
s
chars
=
[]
nums
=
[]
tuples
=
[]
for
item
in
it
:
if
type
(
item
)
is
int
:
nums
.
append
(
item
)
elif
type
(
item
)
is
tuple
:
tuples
.
append
(
item
)
else
:
chars
.
append
(
item
)
nums
.
sort
()
chars
.
sort
()
return
chars
+
nums
tuples
.
sort
()
return
chars
+
nums
+
tuples
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