[Python-checkins] Simplify __all__ in multiprocessing (GH-6856)

INADA Naoki webhook-mailer at python.org
Wed Jul 11 06:22:31 EDT 2018


https://github.com/python/cpython/commit/c40278ef95121f04745d3552fe14376faf468329
commit: c40278ef95121f04745d3552fe14376faf468329
branch: master
author: Derek B. Kim <bluewhale8202 at gmail.com>
committer: INADA Naoki <methane at users.noreply.github.com>
date: 2018-07-11T19:22:28+09:00
summary:

Simplify __all__ in multiprocessing (GH-6856)

files:
M Lib/multiprocessing/__init__.py
M Lib/multiprocessing/context.py
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py
index 86df63837037..8336f381deca 100644
--- a/Lib/multiprocessing/__init__.py
+++ b/Lib/multiprocessing/__init__.py
@@ -19,9 +19,8 @@
 # Copy stuff from default context
 #
 
-globals().update((name, getattr(context._default_context, name))
-                 for name in context._default_context.__all__)
-__all__ = context._default_context.__all__
+__all__ = [x for x in dir(context._default_context) if not x.startswith('_')]
+globals().update((name, getattr(context._default_context, name)) for name in __all__)
 
 #
 # XXX These should not really be documented or public.
diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py
index c98ee4342490..871746b1a047 100644
--- a/Lib/multiprocessing/context.py
+++ b/Lib/multiprocessing/context.py
@@ -5,7 +5,7 @@
 from . import process
 from . import reduction
 
-__all__ = []            # things are copied from here to __init__.py
+__all__ = ()
 
 #
 # Exceptions
@@ -24,7 +24,7 @@ class AuthenticationError(ProcessError):
     pass
 
 #
-# Base type for contexts
+# Base type for contexts. Bound methods of an instance of this type are included in __all__ of __init__.py
 #
 
 class BaseContext(object):
@@ -261,8 +261,6 @@ def get_all_start_methods(self):
             else:
                 return ['fork', 'spawn']
 
-DefaultContext.__all__ = [x for x in dir(DefaultContext) if x[0] != '_']
-
 #
 # Context types for fixed start method
 #
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index c4810a5ce17e..f446ef34fe67 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -4582,6 +4582,12 @@ def test_empty(self):
 
         proc.join()
 
+
+class MiscTestCase(unittest.TestCase):
+    def test__all__(self):
+        # Just make sure names in blacklist are excluded
+        support.check__all__(self, multiprocessing, extra=multiprocessing.__all__,
+                             blacklist=['SUBDEBUG', 'SUBWARNING'])
 #
 # Mixins
 #



More information about the Python-checkins mailing list