Skip to content

Commit

Permalink
Fix copying numpy arrays from netrefs
Browse files Browse the repository at this point in the history
Resolves #236

Closes #256, cleaner solution (?)
  • Loading branch information
coldfix committed Mar 2, 2018
1 parent 64d638b commit 9f45f82
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rpyc/core/netref.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'__init__', '__metaclass__', '__module__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__slots__', '__str__',
'__weakref__', '__dict__', '__members__', '__methods__', '__exit__',
'__array__',
]) | _deleted_netref_attrs
"""the set of attributes that are local to the netref object"""

Expand Down Expand Up @@ -152,6 +151,8 @@ def __getattribute__(self, name):
return object.__getattribute__(self, name)
elif name == "__call__": # IronPython issue #10
return object.__getattribute__(self, "__call__")
elif name == "__array__":
return object.__getattribute__(self, "__array__")
else:
return syncreq(self, consts.HANDLE_GETATTR, name)
def __getattr__(self, name):
Expand Down Expand Up @@ -186,12 +187,6 @@ def __exit__(self, exc, typ, tb):
def __reduce_ex__(self, proto):
return pickle.loads, (syncreq(self, consts.HANDLE_PICKLE, proto),)

# This is not strictly necessary, but a performance optimization:
# Note that protocol=-1 will only work between python interpreters of the
# same version:
def __array__(self):
return pickle.loads(syncreq(self, consts.HANDLE_PICKLE, -1))


def _make_method(name, doc):
"""creates a method with the given name and docstring that invokes
Expand All @@ -214,6 +209,13 @@ def method(self, start, stop, *args):
method.__name__ = name
method.__doc__ = doc
return method
elif name == "__array__":
def __array__(self):
# Note that protocol=-1 will only work between python
# interpreters of the same version.
return pickle.loads(syncreq(self, consts.HANDLE_PICKLE, -1))
__array__.__doc__ = doc
return __array__
else:
def method(_self, *args, **kwargs):
kwargs = tuple(kwargs.items())
Expand Down

0 comments on commit 9f45f82

Please sign in to comment.