From: Antoine Pitrou Date: Tue, 3 Apr 2012 18:12:23 +0000 (+0200) Subject: Issue #14482: Raise a ValueError, not a NameError, when trying to create X-Git-Tag: v3.3.0a3~320^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d20cba8d646ec055851afac5494cc0e72d0dfa8;p=python 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. --- diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index fa6f7b3901..8bb0a3b0d8 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -101,6 +101,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 8de7a8d1d0..298faf73fd 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2331,6 +2331,12 @@ 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, TestInvalidFamily] diff --git a/Misc/NEWS b/Misc/NEWS index 18a8d73e69..45e0c25f1f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -39,6 +39,10 @@ Core and Builtins Library ------- +- 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. + - 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.