[Zope-CVS] SVN: psycopgda/trunk/ Bug fix when converting strings to
unicode. If None is passed to the
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Oct 16 08:38:12 EDT 2004
Log message for revision 28202:
Bug fix when converting strings to unicode. If None is passed to the
converter, it used to crash. Thanks goes to Carroll Kong and Derrick
Hudson for pointing out the problem and solution.
Changed:
U psycopgda/trunk/adapter.py
U psycopgda/trunk/tests.py
-=-
Modified: psycopgda/trunk/adapter.py
===================================================================
--- psycopgda/trunk/adapter.py 2004-10-15 19:35:55 UTC (rev 28201)
+++ psycopgda/trunk/adapter.py 2004-10-16 12:38:12 UTC (rev 28202)
@@ -262,10 +262,11 @@
else:
return timedelta(days=d, hours=hr, minutes=mn, seconds=sc)
+def _conv_string(s):
+ if s is not None:
+ s = s.decode(PG_ENCODING)
+ return s
-def _conv_string(str):
- return str.decode(PG_ENCODING)
-
# User-defined types
DATE = psycopg.new_type((DATE_OID,), "ZDATE", _conv_date)
TIME = psycopg.new_type((TIME_OID,), "ZTIME", _conv_time)
Modified: psycopgda/trunk/tests.py
===================================================================
--- psycopgda/trunk/tests.py 2004-10-15 19:35:55 UTC (rev 28201)
+++ psycopgda/trunk/tests.py 2004-10-16 12:38:12 UTC (rev 28202)
@@ -152,6 +152,7 @@
def test_conv_string(self):
from psycopgda.adapter import _conv_string
+ self.assertEquals(_conv_string(None), None)
self.assertEquals(_conv_string(''), u'')
self.assertEquals(_conv_string('c'), u'c')
self.assertEquals(_conv_string('\xc3\x82\xc2\xa2'), u'\xc2\xa2')
More information about the Zope-CVS
mailing list