py3k - corrections for deprecation warnings reported by python2.6 -3.
- integer division - repr instead of ` Added __hash__ to speedy Proxy funtions - 3.x requires __hash__ if __eq__ is defined. Found problem with comparing two proxy objects.
This commit is contained in:
@@ -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):
|
||||
|
@@ -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):
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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))
|
||||
|
@@ -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
|
||||
|
@@ -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__':
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -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):
|
||||
|
@@ -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())
|
||||
|
@@ -51,7 +51,7 @@ class Test(LimitedTestCase):
|
||||
pass
|
||||
|
||||
try:
|
||||
1/0
|
||||
1//0
|
||||
except:
|
||||
try:
|
||||
with Timeout(DELAY, sys.exc_info()[0]):
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user