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
d8b690f7
Commit
d8b690f7
authored
May 16, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2895: don't crash with bytes as keyword argument names.
parent
bf82e374
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
Lib/test/test_grammar.py
Lib/test/test_grammar.py
+8
-0
Misc/NEWS
Misc/NEWS
+2
-0
Python/getargs.c
Python/getargs.c
+1
-1
No files found.
Lib/test/test_grammar.py
View file @
d8b690f7
...
...
@@ -265,6 +265,14 @@ class GrammarTests(unittest.TestCase):
d22v
(
*
(
1
,
2
,
3
,
4
))
d22v
(
1
,
2
,
*
(
3
,
4
,
5
))
d22v
(
1
,
*
(
2
,
3
),
**
{
'd'
:
4
})
# keyword argument type tests
try
:
str
(
'x'
,
**
{
b'foo'
:
1
})
except
TypeError
:
pass
else
:
self
.
fail
(
'Bytes should not work as keyword argument names'
)
# keyword only argument tests
def
pos0key1
(
*
,
key
):
return
key
pos0key1
(
key
=
100
)
...
...
Misc/NEWS
View file @
d8b690f7
...
...
@@ -12,6 +12,8 @@ What's new in Python 3.0b1?
Core and Builtins
-----------------
- Issue 2895: Don't crash when given bytes objects as keyword names.
- Issue 2798: When parsing arguments with PyArg_ParseTuple, the "s" code now
allows any unicode string and returns a utf-8 encoded buffer, just like the
"s#" code already does. The "z" code was corrected as well.
...
...
Python/getargs.c
View file @
d8b690f7
...
...
@@ -1532,7 +1532,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
while
(
PyDict_Next
(
keywords
,
&
pos
,
&
key
,
&
value
))
{
int
match
=
0
;
char
*
ks
;
if
(
!
Py
String_Check
(
key
)
&&
!
Py
Unicode_Check
(
key
))
{
if
(
!
PyUnicode_Check
(
key
))
{
PyErr_SetString
(
PyExc_TypeError
,
"keywords must be strings"
);
return
cleanreturn
(
0
,
freelist
);
...
...
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