bpo-43682: Make staticmethod objects callable (GH-25117)
Static methods (@staticmethod) are now callable as regular functions.
diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py
index 7d0243a..d435345 100644
--- a/Lib/test/test_decorators.py
+++ b/Lib/test/test_decorators.py
@@ -91,14 +91,18 @@ def func(x):
getattr(func, attr))
self.assertEqual(repr(wrapper), format_str.format(func))
-
- self.assertRaises(TypeError, wrapper, 1)
+ return wrapper
def test_staticmethod(self):
- self.check_wrapper_attrs(staticmethod, '<staticmethod({!r})>')
+ wrapper = self.check_wrapper_attrs(staticmethod, '<staticmethod({!r})>')
+
+ # bpo-43682: Static methods are callable since Python 3.10
+ self.assertEqual(wrapper(1), 1)
def test_classmethod(self):
- self.check_wrapper_attrs(classmethod, '<classmethod({!r})>')
+ wrapper = self.check_wrapper_attrs(classmethod, '<classmethod({!r})>')
+
+ self.assertRaises(TypeError, wrapper, 1)
def test_dotted(self):
decorators = MiscDecorators()
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index e94ebd3..9bde0c7 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -1142,7 +1142,7 @@ def sm(x, y):
'''A static method'''
...
self.assertEqual(self._get_summary_lines(X.__dict__['sm']),
- 'sm(...)\n'
+ 'sm(x, y)\n'
' A static method\n')
self.assertEqual(self._get_summary_lines(X.sm), """\
sm(x, y)