Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slice object may not be dumpable #62

Closed
pyscripter opened this issue Jan 7, 2012 · 4 comments
Closed

slice object may not be dumpable #62

pyscripter opened this issue Jan 7, 2012 · 4 comments
Assignees

Comments

@pyscripter
Copy link
Contributor

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
@tomerfiliba
Copy link
Collaborator

no can do... slice objects have to pass by value. i think it's a constraint of built in types. anyhow, what was the exception? i'd need full traceback

@pyscripter
Copy link
Contributor Author

With the version on the repository using python 3.2 32 bit:

a) Start classic server.
b) In a python console do:

conn = rpyc.classic.connect("localhost")
conn.execute('import numpy')
conn.execute('sl = slice(numpy.int32(2),None,None)')
sl = conn.namespace.sl

This crashes rpyc. The output from the classic_server is:

C:\Program Files (x86)\Python32\Scripts>..\python.exe rpyc_classic.py
INFO:SLAVE/18812:server started on [0.0.0.0]:18812
INFO:SLAVE/18812:accepted 127.0.0.1:50125
INFO:SLAVE/18812:welcome [127.0.0.1]:50125
INFO:SLAVE/18812:goodbye [127.0.0.1]:50125
ERROR:SLAVE/18812:client connection terminated abruptly
Traceback (most recent call last):
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\utils\server.py",
line 165, in _authenticate_and_serve_client
self._serve_client(sock2, credentials)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\utils\server.py",
line 190, in _serve_client
conn.serve_all()
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 383, in serve_all
self.serve(0.1)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 374, in serve
self._dispatch(data)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 342, in _dispatch
self._dispatch_request(seq, args)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 301, in _dispatch_request
self._send_reply(seq, res)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 224, in _send_reply
self._send(consts.MSG_REPLY, seq, self._box(obj))
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 213, in _send
data = brine.dump((msg, seq, args))
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 337, in dump
_dump(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 197, in _dump_tuple
_dump(item, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 197, in _dump_tuple
_dump(item, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 99, in _dump_slice
_dump((obj.start, obj.stop, obj.step), stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 197, in _dump_tuple
_dump(item, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 200, in _undumpable
raise TypeError("cannot dump %r" % (obj,))
TypeError: cannot dump 2
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python32\lib\threading.py", line 736, in _bootstr
ap_inner
self.run()
File "C:\Program Files (x86)\Python32\lib\threading.py", line 689, in run
self._target(_self._args, *_self._kwargs)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\utils\server.py",
line 165, in _authenticate_and_serve_client
self._serve_client(sock2, credentials)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\utils\server.py",
line 190, in _serve_client
conn.serve_all()
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 383, in serve_all
self.serve(0.1)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 374, in serve
self._dispatch(data)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 342, in _dispatch
self._dispatch_request(seq, args)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 301, in _dispatch_request
self._send_reply(seq, res)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 224, in _send_reply
self._send(consts.MSG_REPLY, seq, self._box(obj))
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\protocol.py"
, line 213, in _send
data = brine.dump((msg, seq, args))
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 337, in dump
_dump(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 197, in _dump_tuple
_dump(item, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 197, in _dump_tuple
_dump(item, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 99, in _dump_slice
_dump((obj.start, obj.stop, obj.step), stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 197, in _dump_tuple
_dump(item, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 203, in _dump
_dump_registry.get(type(obj), _undumpable)(obj, stream)
File "C:\Program Files (x86)\Python32\lib\site-packages\rpyc\core\brine.py", l
ine 200, in _undumpable
raise TypeError("cannot dump %r" % (obj,))
TypeError: cannot dump 2

@pyscripter
Copy link
Contributor Author

With the suggested changes it works fine:

conn.execute('sl = slice(numpy.int32(2),None,None)')
conn.namespace['sl']
slice(2, None, None)

@tomerfiliba
Copy link
Collaborator

i ended up using your original fix -- i think it should work okay. could you test that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants