[Numpy-discussion] Segfault for np.lookfor

Charles R Harris charlesr.harris@gmail....
Mon Aug 15 20:43:57 CDT 2011


On Mon, Aug 15, 2011 at 7:09 PM, Charles R Harris <charlesr.harris@gmail.com
> wrote:

>
>
> On Mon, Aug 15, 2011 at 6:56 PM, Charles R Harris <
> charlesr.harris@gmail.com> wrote:
>
>>
>>
>> On Mon, Aug 15, 2011 at 3:53 PM, Matthew Brett <matthew.brett@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> On current trunk, all tests pass but running the (forgive my language)
>>> doctests, I found this:
>>>
>>> In [1]: import numpy as np
>>>
>>> In [2]: np.__version__
>>> Out[2]: '2.0.0.dev-730b861'
>>>
>>> In [3]: np.lookfor('cos')
>>> Segmentation fault
>>>
>>> on:
>>>
>>> Linux angela 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC
>>> 2011 x86_64 x86_64 x86_64 GNU/Linux
>>> Ubuntu Natty Python 2.7.1+
>>>
>>>
>> The problem is somewhere in print_coercion_tables.py
>>
>>
> Or more precisely, it triggered by importing  print_coercion_tables.py. I
> don't think lookfor should be doing that, but in any case:
>
> array + scalar
> + ? b h i l q p B H I L Q P e f d g F D G S U V O M m
> ? ? b h i l l l B H I L L L e f d g F D G O O # O ! m
> b b b b b b b b b b b b b b e f d g F D G O O # O ! m
> h h h h h h h h h h h h h h f f d g F D G O O # O ! m
> i i i i i i i i i i i i i i d d d g D D G O O # O ! m
> l l l l l l l l l l l l l l d d d g D D G O O # O ! m
> q l l l l l l l l l l l l l d d d g D D G O O # O ! m
> p l l l l l l l l l l l l l d d d g D D G O O # O ! m
> B B B B B B B B B B B B B B e f d g F D G O O # O ! m
> H H H H H H H H H H H H H H f f d g F D G O O # O ! m
> I I I I I I I I I I I I I I d d d g D D G O O # O ! m
> L L L L L L L L L L L L L L d d d g D D G O O # O ! m
> Q L L L L L L L L L L L L L d d d g D D G O O # O ! m
> P L L L L L L L L L L L L L d d d g D D G O O # O ! m
> e e e e e e e e e e e e e e e e e e F F F O O # O ! #
> f f f f f f f f f f f f f f f f f f F F F O O # O ! #
> d d d d d d d d d d d d d d d d d d D D D O O # O ! #
> g g g g g g g g g g g g g g g g g g G G G O O # O ! #
> F F F F F F F F F F F F F F F F F F F F F O O # O ! #
> D D D D D D D D D D D D D D D D D D D D D O O # O ! #
> G G G G G G G G G G G G G G G G G G G G G O O # O ! #
> S O O O O O O O O O O O O O O O O O O O O O O # O ! O
> U O O O O O O O O O O O O O O O O O O O O O O # O ! O
> Segmentation fault (core dumped)
>

A quick fix is to put the print statements in a function.

diff --git a/numpy/testing/print_coercion_tables.py
b/numpy/testing/print_coercion_tables.p
index d875449..3bc9253 100755
--- a/numpy/testing/print_coercion_tables.py
+++ b/numpy/testing/print_coercion_tables.py
@@ -65,22 +65,23 @@ def print_coercion_table(ntypes, inputfirstvalue,
inputsecondvalue, fir
             print char,
         print

-print "can cast"
-print_cancast_table(np.typecodes['All'])
-print
-print "In these tables, ValueError is '!', OverflowError is '@', TypeError
is '#'"
-print
-print "scalar + scalar"
-print_coercion_table(np.typecodes['All'], 0, 0, False)
-print
-print "scalar + neg scalar"
-print_coercion_table(np.typecodes['All'], 0, -1, False)
-print
-print "array + scalar"
-print_coercion_table(np.typecodes['All'], 0, 0, True)
-print
-print "array + neg scalar"
-print_coercion_table(np.typecodes['All'], 0, -1, True)
-print
-print "promote_types"
-print_coercion_table(np.typecodes['All'], 0, 0, False, True)
+def printem():
+    print "can cast"
+    print_cancast_table(np.typecodes['All'])
+    print
+    print "In these tables, ValueError is '!', OverflowError is '@',
TypeError is '#'"
+    print
+    print "scalar + scalar"
+    print_coercion_table(np.typecodes['All'], 0, 0, False)
+    print
+    print "scalar + neg scalar"
+    print_coercion_table(np.typecodes['All'], 0, -1, False)
+    print
+    print "array + scalar"
+    print_coercion_table(np.typecodes['All'], 0, 0, True)
+    print
+    print "array + neg scalar"
+    print_coercion_table(np.typecodes['All'], 0, -1, True)
+    print
+    print "promote_types"
+    print_coercion_table(np.typecodes['All'], 0, 0, False, True)

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110815/1ce9d143/attachment-0001.html 


More information about the NumPy-Discussion mailing list