Changeset: 3135505afb9c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3135505afb9c
Modified Files:
python/monetdb/mapi2.py
python/test/runtests.py
Branch: default
Log Message:
added a low level test to check if correct number of bytes is received
diffs (45 lines):
diff -r 4c375e17fda0 -r 3135505afb9c python/monetdb/mapi2.py
--- a/python/monetdb/mapi2.py Thu May 13 13:16:30 2010 +0200
+++ b/python/monetdb/mapi2.py Thu May 13 13:44:18 2010 +0200
@@ -18,7 +18,7 @@
"""
this is the python 2.* implementation of the mapi API.
-If you use python 3.* you should use mapi3.py
+the python 3.* implementation is in mapi3.py
"""
import socket
@@ -214,9 +214,6 @@
last = 0
while not last:
flag = self.__getbytes(2)
- if len(flag) != 2:
- raise OperationalError("server returned %s bytes, I need 2" %
- len(flag))
# unpack (little endian short)
unpacked = struct.unpack('<H', flag)[0]
@@ -234,7 +231,10 @@
def __getbytes(self, bytes):
"""Read an amount of bytes from the socket"""
try:
- return self.socket.recv(bytes)
+ recv = self.socket.recv(bytes)
+ if len(recv) != bytes:
+ raise OperationalError("expected %s bytes but received %s
bytes" % bytes, len(recv))
+ return recv
except socket.error, error:
raise OperationalError(error[1])
diff -r 4c375e17fda0 -r 3135505afb9c python/test/runtests.py
--- a/python/test/runtests.py Thu May 13 13:16:30 2010 +0200
+++ b/python/test/runtests.py Thu May 13 13:44:18 2010 +0200
@@ -32,6 +32,7 @@
try:
import monetdb.sql
except ImportError:
+ print "monetdb python API not found, using local monetdb python API"
import sys
parent = os.path.join(sys.path[0], '..')
sys.path.append(parent)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list