[Monetdb-developers] a little unicode fix in MapiClient.py
Steps to reproduce problem: 1. MonetDB-4.10.2, Python 2.3.4, Gentoo Linux 2005.0, LANG=ru_RU.KOI8-R 2. Start monetdb mil server 3. Start MapiClient.py 4. Type following command: vars(); 5. Script fails with the following output:
#MapiClient (python) connected to localhost:50000 as max
vars();
Traceback (most recent call last): File "/usr/bin/MapiClient.py", line 77, in ? main(sys.argv) File "/usr/bin/MapiClient.py", line 60, in main res = s.cmd(line) File "/usr/share/MonetDB/python/Mapi.py", line 116, in cmd return self.result() File "/usr/share/MonetDB/python/Mapi.py", line 67, in result while buffer[-len(self.prompt1):] != self.prompt1 and \ UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 0: ordinal not in range(128)
Possible patch:
--- MonetDB-4.10.2/src/mapi/clients/python/MapiClient.py.in 2006-01-20 23:36:49.000000000 +0700 +++ MonetDB-4.10.2/src/mapi/clients/python/MapiClient.py.in.fixed 2006-05-14 15:15:19.000000000 +0800 @@ -57,7 +57,7 @@ sys.stdout.write(s.prompt) line = fi.readline() while line and line != "quit;\n": - res = s.cmd(line) + res = s.cmd(line).encode('utf-8') print res sys.stdout.write(s.prompt.encode('utf-8')) line = fi.readline()
Hi Max,
Thanks for your interest in MonetDB and your patch.
On 14-05-2006 11:21:45 +0400, Max wrote:
Steps to reproduce problem:
- MonetDB-4.10.2, Python 2.3.4, Gentoo Linux 2005.0, LANG=ru_RU.KOI8-R
Just for the record, are you running x86, ppc, amd64...?
#MapiClient (python) connected to localhost:50000 as max
vars();
Traceback (most recent call last):
[snip]
File "/usr/share/MonetDB/python/Mapi.py", line 67, in result while buffer[-len(self.prompt1):] != self.prompt1 and \ UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 0: ordinal not in range(128)
Possible patch:
--- MonetDB-4.10.2/src/mapi/clients/python/MapiClient.py.in 2006-01-20 23:36:49.000000000 +0700 +++ MonetDB-4.10.2/src/mapi/clients/python/MapiClient.py.in.fixed 2006-05-14 15:15:19.000000000 +0800 @@ -57,7 +57,7 @@ sys.stdout.write(s.prompt) line = fi.readline() while line and line != "quit;\n":
res = s.cmd(line)
res = s.cmd(line).encode('utf-8') print res sys.stdout.write(s.prompt.encode('utf-8')) line = fi.readline()
Your patch looks most reasonable to me, but I'm not a python expert. Maybe Niels or Sjoerd can have a look at this. This patch solves the problem for you, right? I guess in your vars there are some paths with Russian characters which triggers the problem, or something like that?
Regards
On Sun, May 14, 2006 at 10:19:41AM +0200, Fabian Groffen wrote:
Max
Your fix does indeed fix the problem for a machine with utf8 locale. However there exist many other unicode encodings. As pythons unicode implementation doesn't allow for asking for the 'default' unicode encoding we cannot generally fix this. Therefor I think we should stay with the current code which takes the default encoding (ascii), which indeed has problems with our utf8 input strings. I Hope this explains the problem a bit.
Niels
Hi Max,
Thanks for your interest in MonetDB and your patch.
On 14-05-2006 11:21:45 +0400, Max wrote:
Steps to reproduce problem:
- MonetDB-4.10.2, Python 2.3.4, Gentoo Linux 2005.0, LANG=ru_RU.KOI8-R
Just for the record, are you running x86, ppc, amd64...?
#MapiClient (python) connected to localhost:50000 as max
vars();
Traceback (most recent call last):
[snip]
File "/usr/share/MonetDB/python/Mapi.py", line 67, in result while buffer[-len(self.prompt1):] != self.prompt1 and \ UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 0: ordinal not in range(128)
Possible patch:
--- MonetDB-4.10.2/src/mapi/clients/python/MapiClient.py.in 2006-01-20 23:36:49.000000000 +0700 +++ MonetDB-4.10.2/src/mapi/clients/python/MapiClient.py.in.fixed 2006-05-14 15:15:19.000000000 +0800 @@ -57,7 +57,7 @@ sys.stdout.write(s.prompt) line = fi.readline() while line and line != "quit;\n":
res = s.cmd(line)
res = s.cmd(line).encode('utf-8') print res sys.stdout.write(s.prompt.encode('utf-8')) line = fi.readline()
Your patch looks most reasonable to me, but I'm not a python expert. Maybe Niels or Sjoerd can have a look at this. This patch solves the problem for you, right? I guess in your vars there are some paths with Russian characters which triggers the problem, or something like that?
Regards
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&da... _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
participants (3)
-
Fabian Groffen
-
Max
-
Niels Nes