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.
This commit is contained in:
Antoine Pitrou 2012-04-03 20:12:23 +02:00
parent 28b8b94760
commit 6d20cba8d6
3 changed files with 14 additions and 0 deletions

View File

@ -101,6 +101,10 @@ def _validate_family(family):
if sys.platform != 'win32' and family == 'AF_PIPE': if sys.platform != 'win32' and family == 'AF_PIPE':
raise ValueError('Family %s is not recognized.' % family) 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): def address_type(address):
''' '''

View File

@ -2331,6 +2331,12 @@ class TestInvalidFamily(unittest.TestCase):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
multiprocessing.connection.Listener(r'\\.\test') 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, testcases_other = [OtherTest, TestInvalidHandle, TestInitializers,
TestStdinBadfiledescriptor, TestInvalidFamily] TestStdinBadfiledescriptor, TestInvalidFamily]

View File

@ -39,6 +39,10 @@ Core and Builtins
Library 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 - Issue #14151: Raise a ValueError, not a NameError, when trying to create
a multiprocessing Client or Listener with an AF_PIPE type address under a multiprocessing Client or Listener with an AF_PIPE type address under
non-Windows platforms. Patch by Popa Claudiu. non-Windows platforms. Patch by Popa Claudiu.