diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-03 18:13:45 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-03 18:13:45 (GMT) |
commit | 5c73e8eaf40e092dfb3c2a92195b300afc99d2cf (patch) | |
tree | daf800c64e1ee0274db8c58b1513d5285cd39ed1 /Lib | |
parent | 395c879da7386ef2df503bf3636da65fa6cb60ef (diff) | |
parent | 6d20cba8d646ec055851afac5494cc0e72d0dfa8 (diff) | |
download | cpython-5c73e8eaf40e092dfb3c2a92195b300afc99d2cf.zip cpython-5c73e8eaf40e092dfb3c2a92195b300afc99d2cf.tar.gz cpython-5c73e8eaf40e092dfb3c2a92195b300afc99d2cf.tar.bz2 |
Issue #14482: Raise a ValueError, not a NameError, when trying to create
a multiprocessing Client or Listener with an AF_UNIX type address under
Windows. Patch by Popa Claudiu.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/multiprocessing/connection.py | 4 | ||||
-rw-r--r-- | Lib/test/test_multiprocessing.py | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 954e901..4e45443 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -111,6 +111,10 @@ def _validate_family(family): if sys.platform != 'win32' and family == 'AF_PIPE': raise ValueError('Family %s is not recognized.' % family) + if sys.platform == 'win32' and family == 'AF_UNIX': + # double check + if not hasattr(socket, family): + raise ValueError('Family %s is not recognized.' % family) def address_type(address): ''' diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index b4f511c..2bcdb4e 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2649,6 +2649,10 @@ class TestInvalidFamily(unittest.TestCase): with self.assertRaises(ValueError): multiprocessing.connection.Listener(r'\\.\test') + @unittest.skipUnless(WIN32, "skipped on non-Windows platforms") + def test_invalid_family_win32(self): + with self.assertRaises(ValueError): + multiprocessing.connection.Listener('/var/test.pipe') testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, TestStdinBadfiledescriptor, TestWait, TestInvalidFamily] |