diff --git a/eventlet/saranwrap.py b/eventlet/saranwrap.py index 3587935..5455e50 100644 --- a/eventlet/saranwrap.py +++ b/eventlet/saranwrap.py @@ -117,7 +117,7 @@ def _read_response(id, attribute, input, cp): """local helper method to read respones from the rpc server.""" try: str = _read_lp_hunk(input) - _prnt(`str`) + _prnt(repr(str)) response = Pickle.loads(str) except (AttributeError, DeadProcess, Pickle.UnpicklingError), e: raise UnrecoverableError(e) @@ -577,7 +577,7 @@ class Server(object): _log("responding with: %s" % body) #_log("objects: %s" % self._objects) s = Pickle.dumps(body) - _log(`s`) + _log(repr(s)) _write_lp_hunk(self._out, s) def write_exception(self, e): diff --git a/eventlet/tpool.py b/eventlet/tpool.py index 0b95e45..b9b2e11 100644 --- a/eventlet/tpool.py +++ b/eventlet/tpool.py @@ -169,7 +169,7 @@ class Proxy(object): def __getattr__(self,attr_name): f = getattr(self._obj,attr_name) - if not callable(f): + if not hasattr(f, '__call__'): if (isinstance(f, self._autowrap) or attr_name in self._autowrap_names): return Proxy(f, self._autowrap) @@ -199,6 +199,8 @@ class Proxy(object): # wrapped object in such a way that they would block def __eq__(self, rhs): return self._obj.__eq__(rhs) + def __hash__(self): + return self._obj.__hash__() def __repr__(self): return self._obj.__repr__() def __str__(self): diff --git a/tests/convenience_test.py b/tests/convenience_test.py index a3be65f..64aba0a 100644 --- a/tests/convenience_test.py +++ b/tests/convenience_test.py @@ -30,7 +30,7 @@ class TestServe(LimitedTestCase): # tests that the server closes the client sock on handle() exception def crasher(sock,addr): sock.recv(1024) - 0/0 + 0//0 l = eventlet.listen(('localhost', 0)) gt = eventlet.spawn(eventlet.serve, l, crasher) @@ -44,7 +44,7 @@ class TestServe(LimitedTestCase): def crasher(sock,addr): sock.recv(1024) sock.close() - 0/0 + 0//0 l = eventlet.listen(('localhost', 0)) gt = eventlet.spawn(eventlet.serve, l, crasher) diff --git a/tests/hub_test.py b/tests/hub_test.py index 7629be6..ccfc5c4 100644 --- a/tests/hub_test.py +++ b/tests/hub_test.py @@ -51,7 +51,7 @@ class TestExceptionInMainloop(LimitedTestCase): assert delay >= DELAY*0.9, 'sleep returned after %s seconds (was scheduled for %s)' % (delay, DELAY) def fail(): - 1/0 + 1//0 hubs.get_hub().schedule_call_global(0, fail) diff --git a/tests/parse_results.py b/tests/parse_results.py index 62feac5..44bd786 100644 --- a/tests/parse_results.py +++ b/tests/parse_results.py @@ -46,7 +46,7 @@ def parse_unittest_output(s): fail = int(fail or '0') error = int(error or '0') else: - assert ok_match, `s` + assert ok_match, repr(s) timeout_match = re.search('^===disabled because of timeout: (\d+)$', s, re.M) if timeout_match: timeout = int(timeout_match.group(1)) diff --git a/tests/saranwrap_test.py b/tests/saranwrap_test.py index b96a08b..ba71c20 100644 --- a/tests/saranwrap_test.py +++ b/tests/saranwrap_test.py @@ -82,7 +82,6 @@ class TestSaranwrap(LimitedTestCase): self.assertEqual(1, prox['a']) self.assertEqual(str(my_object), str(prox)) self.assertEqual('saran:' + repr(my_object), repr(prox)) - self.assertEqual('saran:' + `my_object`, `prox`) @skip_on_windows @skip_with_pyevent diff --git a/tests/test__greenness.py b/tests/test__greenness.py index 65ef8b4..27f507d 100644 --- a/tests/test__greenness.py +++ b/tests/test__greenness.py @@ -40,7 +40,7 @@ class TestGreenness(unittest.TestCase): urllib2.urlopen('http://127.0.0.1:%s' % self.port) assert False, 'should not get there' except urllib2.HTTPError, ex: - assert ex.code == 501, `ex` + assert ex.code == 501, repr(ex) self.assertEqual(self.server.request_count, 1) if __name__ == '__main__': diff --git a/tests/test__refcount.py b/tests/test__refcount.py index 553971a..8a66f3c 100644 --- a/tests/test__refcount.py +++ b/tests/test__refcount.py @@ -31,7 +31,7 @@ def handle_request(s, raise_on_timeout): return #print 'handle_request - accepted' res = conn.recv(100) - assert res == 'hello', `res` + assert res == 'hello', repr(res) #print 'handle_request - recvd %r' % res res = conn.send('bye') #print 'handle_request - sent %r' % res @@ -46,7 +46,7 @@ def make_request(port): res = s.send('hello') #print 'make_request - sent %s' % res res = s.recv(100) - assert res == 'bye', `res` + assert res == 'bye', repr(res) #print 'make_request - recvd %r' % res #s.close() diff --git a/tests/test__twistedutil.py b/tests/test__twistedutil.py index e7c56fc..afa9ee5 100644 --- a/tests/test__twistedutil.py +++ b/tests/test__twistedutil.py @@ -29,7 +29,7 @@ class Test(unittest.TestCase): def test_block_on_already_succeed(self): d = defer.succeed('hey corotwine') res = block_on(d) - assert res == 'hey corotwine', `res` + assert res == 'hey corotwine', repr(res) @requires_twisted def test_block_on_already_failed(self): diff --git a/tests/test__twistedutil_protocol.py b/tests/test__twistedutil_protocol.py index f533d89..53381f4 100644 --- a/tests/test__twistedutil_protocol.py +++ b/tests/test__twistedutil_protocol.py @@ -160,7 +160,7 @@ class TestGreenTransport_bufsize1(TestGreenTransport): # self.conn.write('hello\r\n') # sleep(DELAY*1.5) # make sure the rest of data arrives # try: -# 1/0 +# 1//0 # except: # #self.conn.loseConnection(failure.Failure()) # does not work, why? # spawn(self.conn._queue.send_exception, *sys.exc_info()) @@ -176,7 +176,7 @@ class TestGreenTransport_bufsize1(TestGreenTransport): # self.assertEqual('you said hello. ', self.conn.recv()) # sleep(DELAY*1.5) # make sure the rest of data arrives # try: -# 1/0 +# 1//0 # except: # #self.conn.loseConnection(failure.Failure()) # does not work, why? # spawn(self.conn._queue.send_exception, *sys.exc_info()) diff --git a/tests/timeout_test_with_statement.py b/tests/timeout_test_with_statement.py index 7ce29b7..48fe0b5 100644 --- a/tests/timeout_test_with_statement.py +++ b/tests/timeout_test_with_statement.py @@ -51,7 +51,7 @@ class Test(LimitedTestCase): pass try: - 1/0 + 1//0 except: try: with Timeout(DELAY, sys.exc_info()[0]): diff --git a/tests/tpool_test.py b/tests/tpool_test.py index bd61e79..bb954a7 100644 --- a/tests/tpool_test.py +++ b/tests/tpool_test.py @@ -74,7 +74,6 @@ class TestTpool(LimitedTestCase): self.assertEqual(1, prox['a']) self.assertEqual(str(my_object), str(prox)) self.assertEqual(repr(my_object), repr(prox)) - self.assertEqual(`my_object`, `prox`) @skip_with_pyevent def test_wrap_module_class(self): @@ -93,6 +92,17 @@ class TestTpool(LimitedTestCase): exp3 = prox.compile('/') self.assert_(exp1 != exp3) + @skip_with_pyevent + def test_wrap_hash(self): + prox1 = tpool.Proxy(''+'A') + prox2 = tpool.Proxy('A'+'') + self.assert_(prox1=='A') + self.assert_('A'==prox2) + #self.assert_(prox1==prox2) FIXME - could __eq__ unwrap rhs if it is other proxy? + self.assertEqual(hash(prox1), hash(prox2)) + proxList = tpool.Proxy([]) + self.assertRaises(TypeError, hash, proxList) + @skip_with_pyevent def test_wrap_nonzero(self): prox = tpool.Proxy(re)