[3.12] gh-127537: Add __class_getitem__ to the python implementation of functools.partial (#127537) (#128282)

gh-127537: Add __class_getitem__ to the python implementation of functools.partial (#127537)

(cherry picked from commit 401bba6b58)

Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de>
This commit is contained in:
Shantanu 2024-12-26 17:25:07 -08:00 committed by GitHub
parent f699151c87
commit 82dbfbfec9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -390,6 +390,13 @@ class TestPartial:
f = self.partial(object)
self.assertRaises(TypeError, f.__setstate__, BadSequence())
def test_partial_genericalias(self):
alias = self.partial[int]
self.assertIs(alias.__origin__, self.partial)
self.assertEqual(alias.__args__, (int,))
self.assertEqual(alias.__parameters__, ())
@unittest.skipUnless(c_functools, 'requires the C _functools module')
class TestPartialC(TestPartial, unittest.TestCase):
if c_functools: