[Numpy-discussion] Please keep Numpy master working on Py3

Mark Wiebe mwwiebe at gmail.com
Tue Feb 1 19:42:04 EST 2011


On Tue, Feb 1, 2011 at 3:58 PM, Pauli Virtanen <pav at iki.fi> wrote:

> Hi,
>
> The master branch did not build today on Python 3. Please make sure that
> your code works correctly also on Python 3, before pushing it.
>

Sorry about that, I had hoped to be able to use the build-bot to
test/diagnose the issues, but it's down and I didn't pursue it further.


>
>    ***
>
> I mostly fixed the stuff for now, mostly just the usual bytes vs unicode.
>
> Thanks.


> On Python 3, the tests however give two non-obvious failures -- I'm not
> sure if it's just a matter of the raised exception having a different
> type on Py2 vs Py3, or if it reflects something going wrong. Mark, do you
> have ideas?
>

 Sure, taking a look.

======================================================================
> ERROR: test_new_iterator.test_iter_buffering_delayed_alloc
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/usr/local/lib/python3.1/dist-packages/nose-1.0.0.dev-py3.1.egg/
> nose/case.py", line 188, in runTest
>    self.test(*self.arg)
>  File "/home/pauli/prj/scipy/numpy2/dist/linux/lib/python3.1/site-
> packages/numpy/core/tests/test_new_iterator.py", line 1471, in
> test_iter_buffering_delayed_alloc
>    assert_raises(ValueError, lambda i:i[0:2], i)
>  File "/home/pauli/prj/scipy/numpy2/dist/linux/lib/python3.1/site-
> packages/numpy/testing/utils.py", line 983, in assert_raises
>    return nose.tools.assert_raises(*args,**kwargs)
>  File "/usr/lib/python3.1/unittest.py", line 589, in assertRaises
>    callableObj(*args, **kwargs)
>  File "/home/pauli/prj/scipy/numpy2/dist/linux/lib/python3.1/site-
> packages/numpy/core/tests/test_new_iterator.py", line 1471, in <lambda>
>    assert_raises(ValueError, lambda i:i[0:2], i)
> TypeError: sequence index must be integer, not 'slice'
>

This looks like it's a problem in new_iterator_pywrap.c, in
PySequenceMethods npyiter_as_sequence.  I got this error when trying to
slice before implementing the slot sq_slice.  I copied the definition from
array_as_sequence, which I thought would already have any adjustments for
Py3.  The value in that slot shouldn't be NULL, though, so I don't know why
it's giving the error, maybe the struct definition changed, and somehow in
the array sequence methods that gets masked?  Or maybe the assignment slice
slot needs to be filled as well, but that doesn't seem right to me.


>
> ======================================================================
> ERROR: test_object_array_self_reference (test_regression.TestRegression)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/home/pauli/prj/scipy/numpy2/dist/linux/lib/python3.1/site-
> packages/numpy/core/tests/test_regression.py", line 1499, in
> test_object_array_self_reference
>    assert_raises(ValueError, oct, a)
>  File "/home/pauli/prj/scipy/numpy2/dist/linux/lib/python3.1/site-
> packages/numpy/testing/utils.py", line 983, in assert_raises
>    return nose.tools.assert_raises(*args,**kwargs)
>  File "/usr/lib/python3.1/unittest.py", line 589, in assertRaises
>    callableObj(*args, **kwargs)
> TypeError: only integer arrays with one element can be converted to an
> index
>

I see, in Py3 oct and hex call array_index instead of array_oct and
array_hex.  I think changing the self-reference exceptions in
int/long/float/oct/hex to TypeError instead of ValueError is probably a good
way to make this consistent.

-Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110201/c7e6fb50/attachment.html>


More information about the NumPy-Discussion mailing list