tomerfiliba/rpyc — Issue #62: slice object may not be dumpable
Author: pyscripter
Created: 2012-01-07 20:51:00+00:00
State: open

I got a crash report from a PyScripter user in which he used the following statement:
numpy_slice = slice(numpy.int32(2),None,None)
This crashed the rpyc server.

Although this is a corner case I am told that numpy users do such things! I suggest the following changes to brine,py.

a) Remove slice from simple types

b) modify dumpable as follows

def dumpable(obj):
"""Indicates whether the given object is *dumpable* by brine

:returns: ``True`` if the object is dumpable (e.g., dumps would succeed),
``False`` otherwise
"""
if type(obj) in simple_types:
return True
if type(obj) in (tuple, frozenset):
return all(dumpable(item) for item in obj)
if type(obj) == slice:
return dumpable(obj.start) and dumpable(obj.step) and dumpable(obj.stop)
return False