8000 gh-127065: Make methodcaller thread-safe and re-entrant by eendebakpt · Pull Request #127245 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-127065: Make methodcaller thread-safe and re-entrant #127245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
eendebakpt committed Nov 28, 2024
commit 5ecf87681f19194a96a0e2c97251087fe95e8e86
13 changes: 13 additions & 0 deletions Lib/test/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ def bar(self, f=42):
return f
def baz(*args, **kwds):
return kwds['name'], kwds['self']
def return_arguments(self, *args, **kwds):
return args, kwds
a = A()
f = operator.methodcaller('foo')
self.assertRaises(IndexError, f, a)
Expand All @@ -498,6 +500,17 @@ def baz(*args, **kwds):
f = operator.methodcaller('baz', name='spam', self='eggs')
self.assertEqual(f(a), ('spam', 'eggs'))

many_positional_arguments = tuple(range(10))
many_kw_arguments = dict(zip('abcdefghij', range(10)))
f = operator.methodcaller('return_arguments', *many_positional_arguments)
self.assertEqual(f(a), (many_positional_arguments, {}))

f = operator.methodcaller('return_arguments', **many_kw_arguments)
self.assertEqual(f(a), ((), many_kw_arguments))

f = operator.methodcaller('return_arguments', *many_positional_arguments, **many_kw_arguments)
self.assertEqual(f(a), (many_positional_arguments, many_kw_arguments))

def test_inplace(self):
operator = self.module
class C(object):
Expand Down
0