[py-svn] r56963 - in py/branch/event/py/execnet: . testing
hpk at codespeak.net
hpk at codespeak.net
Mon Aug 4 12:48:16 CEST 2008
Author: hpk
Date: Mon Aug 4 12:48:15 2008
New Revision: 56963
Modified:
py/branch/event/py/execnet/channel.py
py/branch/event/py/execnet/gateway.py
py/branch/event/py/execnet/testing/test_gateway.py
Log:
have channel.send() fail early on unmarshallable items
Modified: py/branch/event/py/execnet/channel.py
==============================================================================
--- py/branch/event/py/execnet/channel.py (original)
+++ py/branch/event/py/execnet/channel.py Mon Aug 4 12:48:15 2008
@@ -1,6 +1,7 @@
import threading, weakref, sys
import Queue
from cPickle import Pickler, Unpickler
+import marshal
if 'Message' not in globals():
from py.__.execnet.message import Message
@@ -171,6 +172,9 @@
pickler.memo = self._picklememo
pickler.dump(item)
item = f.getvalue()
+ else:
+ if not isinstance(item, str):
+ marshal.dumps(item) # to raise early
data = Message.CHANNEL_DATA(self.id, item)
self.gateway._send(data)
Modified: py/branch/event/py/execnet/gateway.py
==============================================================================
--- py/branch/event/py/execnet/gateway.py (original)
+++ py/branch/event/py/execnet/gateway.py Mon Aug 4 12:48:15 2008
@@ -149,6 +149,8 @@
try:
msg.writeto(self._io)
except:
+ # XXX on the very local side we may not want
+ # this catching but rather propagate
excinfo = self.exc_info()
self._traceex(excinfo)
msg.post_sent(self, excinfo)
Modified: py/branch/event/py/execnet/testing/test_gateway.py
==============================================================================
--- py/branch/event/py/execnet/testing/test_gateway.py (original)
+++ py/branch/event/py/execnet/testing/test_gateway.py Mon Aug 4 12:48:15 2008
@@ -74,6 +74,17 @@
channel = self.fac.new()
py.test.raises(IOError, channel.waitclose, timeout=0.01)
+ def test_channel_makefile_incompatmode(self):
+ channel = self.fac.new()
+ py.test2.raises(ValueError, 'channel.makefile("rw")')
+
+ def test_channel_send_with_pickle_false(self):
+ channel = self.fac.new(pickle=False)
+ class A:
+ pass
+ py.test.raises(ValueError, "channel.send(A)")
+ py.test.raises(ValueError, "channel.send(A())")
+
class PopenGatewayTestSetup:
def setup_class(cls):
cls.gw = py.execnet.PopenGateway()
@@ -377,10 +388,6 @@
s = f.readline()
assert s == "45"
- def test_channel_makefile_incompatmode(self):
- channel = self.gw.newchannel()
- py.test2.raises(ValueError, 'channel.makefile("rw")')
-
def test_pickling(self):
channel = self.gw.remote_exec("""
l1 = channel.receive()
More information about the pytest-commit
mailing list