mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
GH-100242: bring functools.py partial implementation more in line with C code (GH-100244)
in partial.__new__, before checking for the existence of the attribute 'func', first check whether the argument is an instance of partial.
This commit is contained in:
parent
8e36cb7bb2
commit
5a0209fc23
4 changed files with 30 additions and 5 deletions
|
|
@ -185,6 +185,19 @@ class TestPartial:
|
|||
flat = partial(signature, 'asdf', bar=True)
|
||||
self.assertEqual(signature(nested), signature(flat))
|
||||
|
||||
def test_nested_optimization_bug(self):
|
||||
partial = self.partial
|
||||
class Builder:
|
||||
def __call__(self, tag, *children, **attrib):
|
||||
return (tag, children, attrib)
|
||||
|
||||
def __getattr__(self, tag):
|
||||
return partial(self, tag)
|
||||
|
||||
B = Builder()
|
||||
m = B.m
|
||||
assert m(1, 2, a=2) == ('m', (1, 2), dict(a=2))
|
||||
|
||||
def test_nested_partial_with_attribute(self):
|
||||
# see issue 25137
|
||||
partial = self.partial
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue