]> granicus.if.org Git - python/commitdiff
Issue #11673: Fix multiprocessing.[Raw]Array constructor to accept a size of type...
authorMark Dickinson <mdickinson@enthought.com>
Fri, 25 Mar 2011 22:01:06 +0000 (22:01 +0000)
committerMark Dickinson <mdickinson@enthought.com>
Fri, 25 Mar 2011 22:01:06 +0000 (22:01 +0000)
Lib/multiprocessing/sharedctypes.py
Lib/test/test_multiprocessing.py
Misc/NEWS

index b569fb2f8bdc30dfcdcf2e4c46b548ce2ae1e65b..2430be7510d938f1a75cfbe4a23203ef9995d7ac 100644 (file)
@@ -78,7 +78,7 @@ def RawArray(typecode_or_type, size_or_initializer):
     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):
+    if isinstance(size_or_initializer, (int, long)):
         type_ = type_ * size_or_initializer
         return _new_value(type_)
     else:
index c30246085b5d60568ccd13c72026c1bd8ab685ee..bdfc171253745d9400a95c85241e6a8d9f72cf7b 100644 (file)
@@ -917,6 +917,13 @@ class _TestArray(BaseTestCase):
     def test_rawarray(self):
         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))
index 207d3bc4d8d60e26dde0e2db6339f950076030b7..4344e37b0238c248d29a9ada0cde537af6790b23 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #11673: Fix multiprocessing Array and RawArray constructors to accept a
+  size of type 'long', rather than only accepting 'int'.
+
 - Issue #10042: Fixed the total_ordering decorator to handle cross-type
   comparisons that could lead to infinite recursion.