diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-06-05 18:22:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-05 18:22:31 +0300 |
commit | 142566c028720934325f0b7fe28680afd046e00f (patch) | |
tree | 021875972731bf9271bf07cc05d17f15866ded7a /Lib/multiprocessing/managers.py | |
parent | 6c01ebcc0dfc6be22950fabb46bdc10dcb6202c9 (diff) | |
download | cpython-git-142566c028720934325f0b7fe28680afd046e00f.tar.gz |
[3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)
Turn deprecation warnings added in 3.8 into TypeError.
Diffstat (limited to 'Lib/multiprocessing/managers.py')
-rw-r--r-- | Lib/multiprocessing/managers.py | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py index 7e1818bb09..75b5150f82 100644 --- a/Lib/multiprocessing/managers.py +++ b/Lib/multiprocessing/managers.py @@ -360,36 +360,10 @@ class Server(object): finally: self.stop_event.set() - def create(*args, **kwds): + def create(self, c, typeid, /, *args, **kwds): ''' Create a new shared object and return its id ''' - if len(args) >= 3: - self, c, typeid, *args = args - elif not args: - raise TypeError("descriptor 'create' of 'Server' object " - "needs an argument") - else: - if 'typeid' not in kwds: - raise TypeError('create expected at least 2 positional ' - 'arguments, got %d' % (len(args)-1)) - typeid = kwds.pop('typeid') - if len(args) >= 2: - self, c, *args = args - import warnings - warnings.warn("Passing 'typeid' as keyword argument is deprecated", - DeprecationWarning, stacklevel=2) - else: - if 'c' not in kwds: - raise TypeError('create expected at least 2 positional ' - 'arguments, got %d' % (len(args)-1)) - c = kwds.pop('c') - self, *args = args - import warnings - warnings.warn("Passing 'c' as keyword argument is deprecated", - DeprecationWarning, stacklevel=2) - args = tuple(args) - with self.mutex: callable, exposed, method_to_typeid, proxytype = \ self.registry[typeid] @@ -421,7 +395,6 @@ class Server(object): self.incref(c, ident) return ident, tuple(exposed) - create.__text_signature__ = '($self, c, typeid, /, *args, **kwds)' def get_methods(self, c, token): ''' @@ -1293,26 +1266,15 @@ if HAS_SHMEM: _SharedMemoryTracker(f"shmm_{self.address}_{getpid()}") util.debug(f"SharedMemoryServer started by pid {getpid()}") - def create(*args, **kwargs): + def create(self, c, typeid, /, *args, **kwargs): """Create a new distributed-shared object (not backed by a shared memory block) and return its id to be used in a Proxy Object.""" # Unless set up as a shared proxy, don't make shared_memory_context # a standard part of kwargs. This makes things easier for supplying # simple functions. - if len(args) >= 3: - typeod = args[2] - elif 'typeid' in kwargs: - typeid = kwargs['typeid'] - elif not args: - raise TypeError("descriptor 'create' of 'SharedMemoryServer' " - "object needs an argument") - else: - raise TypeError('create expected at least 2 positional ' - 'arguments, got %d' % (len(args)-1)) if hasattr(self.registry[typeid][-1], "_shared_memory_proxy"): kwargs['shared_memory_context'] = self.shared_memory_context - return Server.create(*args, **kwargs) - create.__text_signature__ = '($self, c, typeid, /, *args, **kwargs)' + return Server.create(self, c, typeid, *args, **kwargs) def shutdown(self, c): "Call unlink() on all tracked shared memory, terminate the Server." |