Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Kirill Smelkov
cpython
Commits
299dc239
Commit
299dc239
authored
Jan 20, 2017
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted().
parents
aecbef40
398ef5c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+10
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/bltinmodule.c
Python/bltinmodule.c
+2
-1
No files found.
Lib/test/test_builtin.py
View file @
299dc239
...
...
@@ -1627,6 +1627,16 @@ class TestSorted(unittest.TestCase):
self
.
assertEqual
(
data
,
sorted
(
copy
,
reverse
=
1
))
self
.
assertNotEqual
(
data
,
copy
)
def
test_bad_arguments
(
self
):
# Issue #29327: The first argument is positional-only.
sorted
([])
with
self
.
assertRaises
(
TypeError
):
sorted
(
iterable
=
[])
# Other arguments are keyword-only
sorted
([],
key
=
None
)
with
self
.
assertRaises
(
TypeError
):
sorted
([],
None
)
def
test_inputtypes
(
self
):
s
=
'abracadabra'
types
=
[
list
,
tuple
,
str
]
...
...
Misc/NEWS
View file @
299dc239
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
-----------------
- Issue #29327: Fixed a crash when pass the iterable keyword argument to
sorted().
- Issue #29034: Fix memory leak and use-after-free in os module (path_converter).
- Issue #29159: Fix regression in bytes(x) when x.__index__() raises Exception.
...
...
Python/bltinmodule.c
View file @
299dc239
...
...
@@ -2128,7 +2128,7 @@ builtin_sorted(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwna
{
PyObject
*
newlist
,
*
v
,
*
seq
,
*
keyfunc
=
NULL
;
PyObject
*
callable
;
static
const
char
*
const
kwlist
[]
=
{
"
iterable
"
,
"key"
,
"reverse"
,
0
};
static
const
char
*
const
kwlist
[]
=
{
""
,
"key"
,
"reverse"
,
0
};
/* args 1-3 should match listsort in Objects/listobject.c */
static
_PyArg_Parser
parser
=
{
"O|Oi:sorted"
,
kwlist
,
0
};
int
reverse
;
...
...
@@ -2147,6 +2147,7 @@ builtin_sorted(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwna
return
NULL
;
}
assert
(
nargs
>=
1
);
v
=
_PyObject_FastCallKeywords
(
callable
,
args
+
1
,
nargs
-
1
,
kwnames
);
Py_DECREF
(
callable
);
if
(
v
==
NULL
)
{
...
...
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