[pypy-issue] Issue #2793: cpyext class subclasses lose attributes (pypy/pypy)

pv issues-reply at bitbucket.org
Sat Apr 7 16:13:16 EDT 2018

New issue 2793: cpyext class subclasses lose attributes


On pypy3 (bcbefe2f5e14, 2018-04-05) the following code fails
import numpy as np
from numpy.testing import assert_allclose

x = np.matrix(np.random.rand(12, 12))

for j in range(20000):
    assert_allclose(x, x)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File ".../env/site-packages/numpy/testing/nose_tools/utils.py", line 1396, in assert_allclose
    verbose=verbose, header=header, equal_nan=equal_nan)
  File ".../env/site-packages/numpy/testing/nose_tools/utils.py", line 769, in assert_array_compare
    reduced = val.ravel()
  File ".../env/site-packages/numpy/matrixlib/defmatrix.py", line 1020, in ravel
    return N.ndarray.ravel(self, order=order)
  File ".../env/site-packages/numpy/matrixlib/defmatrix.py", line 260, in __array_finalize__
    if (isinstance(obj, matrix) and obj._getitem): return
AttributeError: 'matrix' object has no attribute '_getitem'
The `matrix` class seem to lose some of its attributes, apparently when the jit kicks in.

(I guess this was a known bug, but I didn't see an open issue for it.)

More information about the pypy-issue mailing list