]> granicus.if.org Git - python/commitdiff
Issue #14482: Raise a ValueError, not a NameError, when trying to create
authorAntoine Pitrou <solipsis@pitrou.net>
Tue, 3 Apr 2012 18:12:23 +0000 (20:12 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Tue, 3 Apr 2012 18:12:23 +0000 (20:12 +0200)
a multiprocessing Client or Listener with an AF_UNIX type address under
Windows.  Patch by Popa Claudiu.

Lib/multiprocessing/connection.py
Lib/test/test_multiprocessing.py
Misc/NEWS

index fa6f7b39019020e4b31682863af7a7cde01c86db..8bb0a3b0d83d9f1f3077ae7d6255de188005b8cb 100644 (file)
@@ -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):
     '''
index 8de7a8d1d0c3eebfb3df8b1bda5a49477651da77..298faf73fd5d9cbda1bb23f3ce0d2448b6e225ce 100644 (file)
@@ -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]
 
index 18a8d73e694e9932c966b97ce27cc205bd595bfc..45e0c25f1f32047061aef497b1f365fd091505e9 100644 (file)
--- 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.