mirror of
https://github.com/python/cpython.git
synced 2026-03-06 13:00:50 +00:00
merge 3.4
This commit is contained in:
commit
dae2ef1cfa
3 changed files with 15 additions and 2 deletions
|
|
@ -77,9 +77,11 @@ def test_kw_combinations(self):
|
|||
# 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
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ Library
|
|||
lines from the code object, fixing an issue when a lambda function is used as
|
||||
decorator argument. Patch by Thomas Ballinger and Allison Kaptur.
|
||||
|
||||
- The keywords attribute of functools.partial is now always a dictionary.
|
||||
|
||||
- Issue #23811: Add missing newline to the PyCompileError error message.
|
||||
Patch by Alex Shkop.
|
||||
|
||||
|
|
|
|||
|
|
@ -102,8 +102,17 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
}
|
||||
}
|
||||
else {
|
||||
pto->kw = pkw;
|
||||
Py_INCREF(pkw);
|
||||
if (pkw == Py_None) {
|
||||
pto->kw = PyDict_New();
|
||||
if (pto->kw == NULL) {
|
||||
Py_DECREF(pto);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pto->kw = pkw;
|
||||
Py_INCREF(pkw);
|
||||
}
|
||||
}
|
||||
|
||||
pto->weakreflist = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue