diff -r e78e35954fbf Lib/multiprocessing/sharedctypes.py --- a/Lib/multiprocessing/sharedctypes.py Thu Mar 17 12:59:38 2011 -0400 +++ b/Lib/multiprocessing/sharedctypes.py Fri Mar 25 14:39:58 2011 -0500 @@ -34,6 +34,7 @@ import sys import ctypes +from operator import index import weakref from multiprocessing import heap, RLock @@ -78,14 +79,17 @@ Returns a ctypes array allocated from shared memory ''' type_ = typecode_to_type.get(typecode_or_type, typecode_or_type) - if isinstance(size_or_initializer, int): - type_ = type_ * size_or_initializer - return _new_value(type_) - else: + try: + size = index(size_or_initializer) + except TypeError: + # Initializer. type_ = type_ * len(size_or_initializer) result = _new_value(type_) result.__init__(*size_or_initializer) return result + else: + type_ = type_ * size + return _new_value(type_) def Value(typecode_or_type, *args, **kwds): ''' diff -r e78e35954fbf Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py Thu Mar 17 12:59:38 2011 -0400 +++ b/Lib/test/test_multiprocessing.py Fri Mar 25 14:39:58 2011 -0500 @@ -918,6 +918,13 @@ self.test_array(raw=True) @unittest.skipIf(c_int is None, "requires _ctypes") + def test_array_accepts_long(self): + arr = self.Array('i', 10L) + self.assertEqual(len(arr), 10) + raw_arr = self.RawArray('i', 10L) + self.assertEqual(len(raw_arr), 10) + + @unittest.skipIf(c_int is None, "requires _ctypes") def test_getobj_getlock_obj(self): arr1 = self.Array('i', range(10)) lock1 = arr1.get_lock()