Author: Alexander Hesse <[email protected]>
Branch: split-rpython
Changeset: r60183:777d30901063
Date: 2013-01-18 19:55 +0100
http://bitbucket.org/pypy/pypy/changeset/777d30901063/
Log: hg merge default
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -1,6 +1,6 @@
from pypy.interpreter.error import operationerrfmt, OperationError
-from pypy.interpreter.typedef import TypeDef, GetSetProperty
+from pypy.interpreter.typedef import TypeDef, GetSetProperty,
make_weakref_descr
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.module.micronumpy.base import W_NDimArray, convert_to_array,\
ArrayArgumentException, issequence_w
@@ -397,6 +397,16 @@
space.w_False]))
return w_d
+ w_pypy_data = None
+ def fget___pypy_data__(self, space):
+ return self.w_pypy_data
+
+ def fset___pypy_data__(self, space, w_data):
+ self.w_pypy_data = w_data
+
+ def fdel___pypy_data__(self, space):
+ self.w_pypy_data = None
+
# --------------------- operations ----------------------------
def _unaryop_impl(ufunc_name):
@@ -674,8 +684,12 @@
imag = GetSetProperty(W_NDimArray.descr_get_imag,
W_NDimArray.descr_set_imag),
__array_interface__ = GetSetProperty(W_NDimArray.descr_array_iface),
- _from_shape_and_storage = interp2app(descr__from_shape_and_storage,
- as_classmethod=True)
+ __weakref__ = make_weakref_descr(W_NDimArray),
+ _from_shape_and_storage = interp2app(descr__from_shape_and_storage,
+ as_classmethod=True),
+ __pypy_data__ = GetSetProperty(W_NDimArray.fget___pypy_data__,
+ W_NDimArray.fset___pypy_data__,
+ W_NDimArray.fdel___pypy_data__),
)
@unwrap_spec(ndmin=int, copy=bool, subok=bool)
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1615,6 +1615,14 @@
assert (b == [20, 1, 21, 3, 4]).all()
raises(ValueError, "array([1, 2])[array([True, False, True])] = [1, 2,
3]")
+ def test_weakref(self):
+ import _weakref
+ from numpypy import array
+ a = array([1, 2, 3])
+ assert _weakref.ref(a)
+ a = array(42)
+ assert _weakref.ref(a)
+
class AppTestMultiDim(BaseNumpyAppTest):
def test_init(self):
import _numpypy
@@ -2385,3 +2393,14 @@
assert y[0, 1] == 2
y[0, 1] = 42
assert x[1] == 42
+
+ def test___pypy_data__(self):
+ from _numpypy import array
+ x = array([1, 2, 3, 4])
+ x.__pypy_data__ is None
+ obj = object()
+ x.__pypy_data__ = obj
+ assert x.__pypy_data__ is obj
+ del x.__pypy_data__
+ assert x.__pypy_data__ is None
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit