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
65bcdd71
Commit
65bcdd71
authored
May 09, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure .keywords is always a dict
parent
07abcf58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
Lib/test/test_functools.py
Lib/test/test_functools.py
+2
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_functoolsmodule.c
Modules/_functoolsmodule.c
+5
-9
No files found.
Lib/test/test_functools.py
View file @
65bcdd71
...
...
@@ -77,9 +77,11 @@ class TestPartial:
# exercise special code paths for no keyword args in
# either the partial object or the caller
p
=
self
.
partial
(
capture
)
self
.
assertEqual
(
p
.
keywords
,
{})
self
.
assertEqual
(
p
(),
((),
{}))
self
.
assertEqual
(
p
(
a
=
1
),
((),
{
'a'
:
1
}))
p
=
self
.
partial
(
capture
,
a
=
1
)
self
.
assertEqual
(
p
.
keywords
,
{
'a'
:
1
})
self
.
assertEqual
(
p
(),
((),
{
'a'
:
1
}))
self
.
assertEqual
(
p
(
b
=
2
),
((),
{
'a'
:
1
,
'b'
:
2
}))
# keyword args in the call override those in the partial object
...
...
Misc/NEWS
View file @
65bcdd71
...
...
@@ -57,6 +57,8 @@ Library
- Issue #9246: On POSIX, os.getcwd() now supports paths longer than 1025 bytes.
Patch written by William Orr.
- The keywords attribute of functools.partial is now always a dictionary.
- Issues #24099, #24100, and #24101: Fix free-after-use bug in heapq'
s
siftup
and
siftdown
functions
.
...
...
Modules/_functoolsmodule.c
View file @
65bcdd71
...
...
@@ -54,17 +54,13 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
Py_DECREF
(
pto
);
return
NULL
;
}
if
(
kw
!=
NULL
)
{
pto
->
kw
=
PyDict_Copy
(
kw
);
if
(
pto
->
kw
==
NULL
)
{
Py_DECREF
(
pto
);
return
NULL
;
}
}
else
{
pto
->
kw
=
Py_None
;
Py_INCREF
(
Py_None
);
pto
->
kw
=
(
kw
!=
NULL
)
?
PyDict_Copy
(
kw
)
:
PyDict_New
();
if
(
pto
->
kw
==
NULL
)
{
Py_DECREF
(
pto
);
return
NULL
;
}
pto
->
weakreflist
=
NULL
;
pto
->
dict
=
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