Changeset: 218999d4d42a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=218999d4d42a
Modified Files:
clients/python3/monetdb/sql/converters.py
clients/python3/monetdb/sql/pythonize.py
clients/python3/test/dbapi20.py
Branch: default
Log Message:
python3 can't nicely handle escaped special chars and utf8 at the same
time, so solved it this way until i find a better solution
diffs (46 lines):
diff --git a/clients/python3/monetdb/sql/converters.py
b/clients/python3/monetdb/sql/converters.py
--- a/clients/python3/monetdb/sql/converters.py
+++ b/clients/python3/monetdb/sql/converters.py
@@ -23,7 +23,7 @@ from monetdb.sql import monetize
from monetdb.sql import pythonize
class Pythonizer:
- def __init__(self, use_unicode):
+ def __init__(self):
pass
def convert(self, data, type_code):
diff --git a/clients/python3/monetdb/sql/pythonize.py
b/clients/python3/monetdb/sql/pythonize.py
--- a/clients/python3/monetdb/sql/pythonize.py
+++ b/clients/python3/monetdb/sql/pythonize.py
@@ -32,7 +32,7 @@ logger = logging.getLogger("monetdb")
def strip(data):
""" returns a python string, chops off quotes,
replaces escape characters"""
- return bytes(data[1:-1], "utf-8").decode("unicode_escape")
+ return ''.join([w.encode('utf-8').decode('unicode_escape') if '\\' in w
else w for w in re.split('([\000-\200]+)', data[1:-1])])
def py_bool(data):
diff --git a/clients/python3/test/dbapi20.py b/clients/python3/test/dbapi20.py
--- a/clients/python3/test/dbapi20.py
+++ b/clients/python3/test/dbapi20.py
@@ -901,16 +901,8 @@ class DatabaseAPI20Test(unittest.TestCas
try:
cur = con.cursor()
self.executeDDL1(cur)
-
- # in python 3 everything is unicode
- import sys
- major = sys.version_info[0]
- if major == 3:
- args = {'beer': '\N{latin small letter a with acute}'}
- encoded = args['beer']
- else:
- args = {'beer': unicode('\N{latin small letter a with acute}',
'unicode-escape')}
- encoded = args['beer'].encode('utf-8')
+ args = {'beer': '\N{latin small letter a with acute}'}
+ encoded = args['beer']
cur.execute( 'insert into %sbooze values (%%(beer)s)' %
self.table_prefix, args )
cur.execute('select name from %sbooze' % self.table_prefix)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list