summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-04-01 15:25:49 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-04-01 15:25:49 (GMT)
commit93bba8fb8a9c6c6d5df33fed8ca9a17975b45c34 (patch)
treedd629860c909d42b1de5754a58954227e114b1ab /Lib
parent0261d754cd7f6bedf7415d94b18b7b631bfa8a63 (diff)
parent709176f10c1774f608a318171a94371e7d05d98f (diff)
downloadcpython-93bba8fb8a9c6c6d5df33fed8ca9a17975b45c34.zip
cpython-93bba8fb8a9c6c6d5df33fed8ca9a17975b45c34.tar.gz
cpython-93bba8fb8a9c6c6d5df33fed8ca9a17975b45c34.tar.bz2
Issue #14151: Raise a ValueError, not a NameError, when trying to create
a multiprocessing Client or Listener with an AF_PIPE type address under non-Windows platforms. Patch by Popa Claudiu.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/connection.py9
-rw-r--r--Lib/test/test_multiprocessing.py14
2 files changed, 22 insertions, 1 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
index ca0c973..954e901 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -104,6 +104,13 @@ def arbitrary_address(family):
else:
raise ValueError('unrecognized family')
+def _validate_family(family):
+ '''
+ Checks if the family is valid for the current environment.
+ '''
+ if sys.platform != 'win32' and family == 'AF_PIPE':
+ raise ValueError('Family %s is not recognized.' % family)
+
def address_type(address):
'''
@@ -436,6 +443,7 @@ class Listener(object):
or default_family
address = address or arbitrary_address(family)
+ _validate_family(family)
if family == 'AF_PIPE':
self._listener = PipeListener(address, backlog)
else:
@@ -473,6 +481,7 @@ def Client(address, family=None, authkey=None):
Returns a connection to the address of a `Listener`
'''
family = family or address_type(address)
+ _validate_family(family)
if family == 'AF_PIPE':
c = PipeClient(address)
else:
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index d65cf6e..b4f511c 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -2638,8 +2638,20 @@ class TestWait(unittest.TestCase):
p.join()
+#
+# Issue 14151: Test invalid family on invalid environment
+#
+
+class TestInvalidFamily(unittest.TestCase):
+
+ @unittest.skipIf(WIN32, "skipped on Windows")
+ def test_invalid_family(self):
+ with self.assertRaises(ValueError):
+ multiprocessing.connection.Listener(r'\\.\test')
+
+
testcases_other = [OtherTest, TestInvalidHandle, TestInitializers,
- TestStdinBadfiledescriptor, TestWait]
+ TestStdinBadfiledescriptor, TestWait, TestInvalidFamily]
#
#