This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: multiprocessing.Array fails if size parameter is a long
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: RawArray does not accept long
View: 11673
Assigned To: Nosy List: mark.dickinson
Priority: normal Keywords:

Created on 2011-03-25 19:47 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg132143 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-03-25 19:47
[From a problem encountered by an EPD user, analyzed by Robert Kern]

There appears to be an

    if isinstance(size_or_initializer, (int, long)):

check in the Python 2.x source for multiprocessing.RawArray. As a result, the following works (as expected):

Python 2.7.1+ (2.7:24179f82b7de, Mar 25 2011, 19:11:09) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
[49842 refs]
>>> multiprocessing.Array('i', 2)
<SynchronizedArray wrapper for <multiprocessing.sharedctypes.c_int_Array_2 object at 0x10073aae0>>
[65598 refs]

But replacing the '2' with a '2L' makes it fail:

>>> multiprocessing.Array('i', 2L)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mdickinson/Python/cpython/Lib/multiprocessing/__init__.py", line 260, in Array
    return Array(typecode_or_type, size_or_initializer, **kwds)
  File "/Users/mdickinson/Python/cpython/Lib/multiprocessing/sharedctypes.py", line 113, in Array
    obj = RawArray(typecode_or_type, size_or_initializer)
  File "/Users/mdickinson/Python/cpython/Lib/multiprocessing/sharedctypes.py", line 85, in RawArray
    type_ = type_ * len(size_or_initializer)
TypeError: object of type 'long' has no len()
[65655 refs]
msg132145 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-03-25 19:48
Duplicate of issue 11673 :-)
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55881
2011-03-25 19:48:53mark.dickinsonsetstatus: open -> closed
2011-03-25 19:48:38mark.dickinsonsetresolution: duplicate
superseder: RawArray does not accept long
messages: + msg132145
2011-03-25 19:47:07mark.dickinsoncreate