[issue11673] RawArray does not accept long
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
New submission from Robert Kern robert.k...@gmail.com: The constructor for multiprocessing.RawArray() takes an argument that is either an integer size or a sequence to initialize the contents. To determine if the argument is a size, it uses isinstance(x, int). This means that integers that happen to be Python longs cause an error. On Win64 systems, Python ints are still 32-bits, so valid sizes for arrays sometimes must be represented by Python longs. Attached is a patch that uses operator.index() to determine if the object can be used as an integer size. -- components: Library (Lib) files: raw-array-long.diff keywords: patch messages: 132144 nosy: Robert.Kern priority: normal severity: normal status: open title: RawArray does not accept long type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file21396/raw-array-long.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Mark Dickinson dicki...@gmail.com added the comment: Thanks for the patch. Are there practical cases where the operator.index check is more useful that the isinstance(..., (int, long)) check that you originally proposed (off-tracker)? While I agree that it's the right fix in principle, the operator.index check smells a bit like new functionality to me, and risks changing behaviour for those (rare, I hope) user-defined classes that implement both __index__ and sequence methods. -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson stage: - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +jnoller ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Robert Kern robert.k...@gmail.com added the comment: The practical case I was thinking of was numpy integer scalar types, which can crop up without explicitly requesting them, much like the long type. Although, now that I check, I see that single-element numpy arrays also pass index(). Ideally, there would be two functions, one that takes sizes and one that takes sequences, much like numpy has array() and empty(). I can revert my patch to doing the isinstance(x, (int, long)) test as a quick fix. That will allow most of the numpy scalar types that I expect will actually be encountered. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Mark Dickinson dicki...@gmail.com added the comment: The practical case I was thinking of was numpy integer scalar types Hmm, true. But at least numpy.int instances pass an isinstance(..., int) check, right? But that still leaves numpy.intanything other than 32 as a problem on 32-bit systems and Windows, and similarly for 64-bit systems. Ideally, there would be two functions, [...] Also true; shame we can't fix this in 2.x. I'll commit the isinstance(int, long) fix and your tests, since it's both safe and a clear improvement on the current behaviour. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Roundup Robot devnull@devnull added the comment: New changeset 2d183b1dae5a by Mark Dickinson in branch '2.7': Issue #11673: Fix multiprocessing.[Raw]Array constructor to accept a size of type long. Thanks Robert Kern. http://hg.python.org/cpython/rev/2d183b1dae5a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11673] RawArray does not accept long
Robert Kern robert.k...@gmail.com added the comment: numpy.int is just an alias to the builtin int, left for historical reasons. The integer scalar type that has the same width as Python's int (numpy.int32 or numpy.int64, depending) will always pass the isinstance() check. Since it's the default integer type in numpy arrays, it will be the most frequently encountered. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com