"""Program demonstrating the "checksum error"

pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
Python-32(69312) malloc: *** error for object 0x226da0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Python-32(69312) malloc: *** error for object 0x22a1f0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
Python-32(69314) malloc: *** error for object 0x226da0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Python-32(69314) malloc: *** error for object 0x22a1f0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
Python-32(69315) malloc: *** error for object 0x226da0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Python-32(69315) malloc: *** error for object 0x22a1f0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
Segmentation fault
pb-d-128-141-26-181:priop Friedrich$ 

or, when it feels better:

pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
pb-d-128-141-26-181:priop Friedrich$ python bugreport2.py 
Bus error
pb-d-128-141-26-181:priop Friedrich$

... Seems to be somehow memory address dependent ..."""

import numpy
import priop.core

class X:
    def __call__(self, *args):
        return False

def x(*args):
    return False

# I cannot say clearly which function is crucial, in general it seems it 
# does not matter very much what method to overload, overloading many of
# them just increases the probablity to get an error.
numpy.set_numeric_ops(
    absolute=X(),
    add=X(), 
    bitwise_or=X(), 
    bitwise_xor=X(), 
    ceil=X(), 
    conjugate=X(),
    divide=X(),
)

# This also triggers the error:
#numpy.set_numeric_ops(
#    absolute=x,
#    add=x, 
#    bitwise_or=x, 
#    bitwise_xor=x, 
#    ceil=x, 
#    conjugate=x,
#    divide=x,
#)
