[3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)

Turn deprecation warnings added in 3.8 into TypeError.
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index b27ae71..2497c2b 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -668,9 +668,8 @@
         self.assertEqual(16, future.result())
         future = self.executor.submit(capture, 1, self=2, fn=3)
         self.assertEqual(future.result(), ((1,), {'self': 2, 'fn': 3}))
-        with self.assertWarns(DeprecationWarning):
-            future = self.executor.submit(fn=capture, arg=1)
-        self.assertEqual(future.result(), ((), {'arg': 1}))
+        with self.assertRaises(TypeError):
+            self.executor.submit(fn=capture, arg=1)
         with self.assertRaises(TypeError):
             self.executor.submit(arg=1)
 
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 188a29d..024f912 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -603,9 +603,9 @@
                 stack.callback(arg=1)
             with self.assertRaises(TypeError):
                 self.exit_stack.callback(arg=2)
-            with self.assertWarns(DeprecationWarning):
+            with self.assertRaises(TypeError):
                 stack.callback(callback=_exit, arg=3)
-        self.assertEqual(result, [((), {'arg': 3})])
+        self.assertEqual(result, [])
 
     def test_push(self):
         exc_raised = ZeroDivisionError
diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py
index 492b226..43fb7fc 100644
--- a/Lib/test/test_contextlib_async.py
+++ b/Lib/test/test_contextlib_async.py
@@ -358,9 +358,9 @@
                 stack.push_async_callback(arg=1)
             with self.assertRaises(TypeError):
                 self.exit_stack.push_async_callback(arg=2)
-            with self.assertWarns(DeprecationWarning):
+            with self.assertRaises(TypeError):
                 stack.push_async_callback(callback=_exit, arg=3)
-        self.assertEqual(result, [((), {'arg': 3})])
+        self.assertEqual(result, [])
 
     @_async_test
     async def test_async_push(self):
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 8fee1c6..c300270 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -556,11 +556,9 @@
         with self.assertRaises(TypeError):
             class B:
                 method = functools.partialmethod()
-        with self.assertWarns(DeprecationWarning):
+        with self.assertRaises(TypeError):
             class B:
                 method = functools.partialmethod(func=capture, a=1)
-        b = B()
-        self.assertEqual(b.method(2, x=3), ((b, 2), {'a': 1, 'x': 3}))
 
     def test_repr(self):
         self.assertEqual(repr(vars(self.A)['both']),
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 4bc21ea..912badb 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -276,9 +276,8 @@
     def test_arg_errors(self):
         res = self.tracer.runfunc(traced_capturer, 1, 2, self=3, func=4)
         self.assertEqual(res, ((1, 2), {'self': 3, 'func': 4}))
-        with self.assertWarns(DeprecationWarning):
-            res = self.tracer.runfunc(func=traced_capturer, arg=1)
-        self.assertEqual(res, ((), {'arg': 1}))
+        with self.assertRaises(TypeError):
+            self.tracer.runfunc(func=traced_capturer, arg=1)
         with self.assertRaises(TypeError):
             self.tracer.runfunc()
 
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index 662c7f6..483910a 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -30,8 +30,8 @@
         self.assertEqual(collections.UserDict(one=1, two=2), d2)
         # item sequence constructor
         self.assertEqual(collections.UserDict([('one',1), ('two',2)]), d2)
-        with self.assertWarnsRegex(DeprecationWarning, "'dict'"):
-            self.assertEqual(collections.UserDict(dict=[('one',1), ('two',2)]), d2)
+        self.assertEqual(collections.UserDict(dict=[('one',1), ('two',2)]),
+                         {'dict': [('one', 1), ('two', 2)]})
         # both together
         self.assertEqual(collections.UserDict([('one',1), ('two',2)], two=3, three=5), d3)
 
@@ -149,9 +149,8 @@
                          [('dict', 42)])
         self.assertEqual(list(collections.UserDict({}, dict=None).items()),
                          [('dict', None)])
-        with self.assertWarnsRegex(DeprecationWarning, "'dict'"):
-            self.assertEqual(list(collections.UserDict(dict={'a': 42}).items()),
-                             [('a', 42)])
+        self.assertEqual(list(collections.UserDict(dict={'a': 42}).items()),
+                         [('dict', {'a': 42})])
         self.assertRaises(TypeError, collections.UserDict, 42)
         self.assertRaises(TypeError, collections.UserDict, (), ())
         self.assertRaises(TypeError, collections.UserDict.__init__)
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 6f15c03..ce5bbfc 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -1866,20 +1866,10 @@
         f()
         self.assertEqual(res, [((1, 2), {'func': 3, 'obj': 4})])
 
-        res = []
-        with self.assertWarns(DeprecationWarning):
-            f = weakref.finalize(a, func=fin, arg=1)
-        self.assertEqual(f.peek(), (a, fin, (), {'arg': 1}))
-        f()
-        self.assertEqual(res, [((), {'arg': 1})])
-
-        res = []
-        with self.assertWarns(DeprecationWarning):
-            f = weakref.finalize(obj=a, func=fin, arg=1)
-        self.assertEqual(f.peek(), (a, fin, (), {'arg': 1}))
-        f()
-        self.assertEqual(res, [((), {'arg': 1})])
-
+        with self.assertRaises(TypeError):
+            weakref.finalize(a, func=fin, arg=1)
+        with self.assertRaises(TypeError):
+            weakref.finalize(obj=a, func=fin, arg=1)
         self.assertRaises(TypeError, weakref.finalize, a)
         self.assertRaises(TypeError, weakref.finalize)