[New-bugs-announce] [issue11672] multiprocessing.Array fails if size parameter is a long

Mark Dickinson report at bugs.python.org
Fri Mar 25 20:47:09 CET 2011


New submission from Mark Dickinson <dickinsm at gmail.com>:

[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]

----------
components: Library (Lib)
messages: 132143
nosy: mark.dickinson
priority: normal
severity: normal
stage: needs patch
status: open
title: multiprocessing.Array fails if size parameter is a long
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11672>
_______________________________________


More information about the New-bugs-announce mailing list