Skip to content

Commit 142566c

Browse files
[3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)
Turn deprecation warnings added in 3.8 into TypeError.
1 parent 6c01ebc commit 142566c

30 files changed

+45
-330
lines changed

Doc/library/bdb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ The :mod:`bdb` module also defines two classes:
343343

344344
For backwards compatibility. Calls the :meth:`run` method.
345345

346-
.. method:: runcall(func, *args, **kwds)
346+
.. method:: runcall(func, /, *args, **kwds)
347347

348348
Debug a single function call, and return its result.
349349

Doc/library/concurrent.futures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Executor Objects
2828
An abstract class that provides methods to execute calls asynchronously. It
2929
should not be used directly, but through its concrete subclasses.
3030

31-
.. method:: submit(fn, *args, **kwargs)
31+
.. method:: submit(fn, /, *args, **kwargs)
3232

3333
Schedules the callable, *fn*, to be executed as ``fn(*args **kwargs)``
3434
and returns a :class:`Future` object representing the execution of the

Doc/library/contextlib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ Functions and classes provided:
416416
The passed in object is returned from the function, allowing this
417417
method to be used as a function decorator.
418418

419-
.. method:: callback(callback, *args, **kwds)
419+
.. method:: callback(callback, /, *args, **kwds)
420420

421421
Accepts an arbitrary callback function and arguments and adds it to
422422
the callback stack.
@@ -473,7 +473,7 @@ Functions and classes provided:
473473
Similar to :meth:`push` but expects either an asynchronous context manager
474474
or a coroutine function.
475475

476-
.. method:: push_async_callback(callback, *args, **kwds)
476+
.. method:: push_async_callback(callback, /, *args, **kwds)
477477

478478
Similar to :meth:`callback` but expects a coroutine function.
479479

Doc/library/curses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ The module :mod:`curses` defines the following functions:
656656
foreground color on the default background.
657657

658658

659-
.. function:: wrapper(func, ...)
659+
.. function:: wrapper(func, /, *args, **kwargs)
660660

661661
Initialize curses and call another callable object, *func*, which should be the
662662
rest of your curses-using application. If the application raises an exception,

Doc/library/profile.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ functions:
309309
Profile the cmd via :func:`exec` with the specified global and
310310
local environment.
311311

312-
.. method:: runcall(func, *args, **kwargs)
312+
.. method:: runcall(func, /, *args, **kwargs)
313313

314314
Profile ``func(*args, **kwargs)``
315315

Doc/library/trace.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Programmatic Interface
166166
environments. If not defined, *globals* and *locals* default to empty
167167
dictionaries.
168168

169-
.. method:: runfunc(func, *args, **kwds)
169+
.. method:: runfunc(func, /, *args, **kwds)
170170

171171
Call *func* with the given arguments under control of the :class:`Trace`
172172
object with the current tracing parameters.

Doc/library/unittest.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ Test cases
14271427
:class:`TextTestResult` in Python 3.2.
14281428

14291429

1430-
.. method:: addCleanup(function, *args, **kwargs)
1430+
.. method:: addCleanup(function, /, *args, **kwargs)
14311431

14321432
Add a function to be called after :meth:`tearDown` to cleanup resources
14331433
used during the test. Functions will be called in reverse order to the

Doc/library/weakref.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ objects.
240240

241241
.. versionadded:: 3.4
242242

243-
.. class:: finalize(obj, func, *args, **kwargs)
243+
.. class:: finalize(obj, func, /, *args, **kwargs)
244244

245245
Return a callable finalizer object which will be called when *obj*
246246
is garbage collected. Unlike an ordinary weak reference, a finalizer

Lib/bdb.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -618,26 +618,11 @@ def runctx(self, cmd, globals, locals):
618618

619619
# This method is more useful to debug a single function call.
620620

621-
def runcall(*args, **kwds):
621+
def runcall(self, func, /, *args, **kwds):
622622
"""Debug a single function call.
623623
624624
Return the result of the function call.
625625
"""
626-
if len(args) >= 2:
627-
self, func, *args = args
628-
elif not args:
629-
raise TypeError("descriptor 'runcall' of 'Bdb' object "
630-
"needs an argument")
631-
elif 'func' in kwds:
632-
func = kwds.pop('func')
633-
self, *args = args
634-
import warnings
635-
warnings.warn("Passing 'func' as keyword argument is deprecated",
636-
DeprecationWarning, stacklevel=2)
637-
else:
638-
raise TypeError('runcall expected at least 1 positional argument, '
639-
'got %d' % (len(args)-1))
640-
641626
self.reset()
642627
sys.settrace(self.trace_dispatch)
643628
res = None
@@ -649,7 +634,6 @@ def runcall(*args, **kwds):
649634
self.quitting = True
650635
sys.settrace(None)
651636
return res
652-
runcall.__text_signature__ = '($self, func, /, *args, **kwds)'
653637

654638

655639
def set_trace():

Lib/cProfile.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,12 @@ def runctx(self, cmd, globals, locals):
103103
return self
104104

105105
# This method is more useful to profile a single function call.
106-
def runcall(*args, **kw):
107-
if len(args) >= 2:
108-
self, func, *args = args
109-
elif not args:
110-
raise TypeError("descriptor 'runcall' of 'Profile' object "
111-
"needs an argument")
112-
elif 'func' in kw:
113-
func = kw.pop('func')
114-
self, *args = args
115-
import warnings
116-
warnings.warn("Passing 'func' as keyword argument is deprecated",
117-
DeprecationWarning, stacklevel=2)
118-
else:
119-
raise TypeError('runcall expected at least 1 positional argument, '
120-
'got %d' % (len(args)-1))
121-
106+
def runcall(self, func, /, *args, **kw):
122107
self.enable()
123108
try:
124109
return func(*args, **kw)
125110
finally:
126111
self.disable()
127-
runcall.__text_signature__ = '($self, func, /, *args, **kw)'
128112

129113
def __enter__(self):
130114
self.enable()

0 commit comments

Comments
 (0)