Author: phd
Date: 2008-07-11 09:29:51 -0600 (Fri, 11 Jul 2008)
New Revision: 3503
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/converters.py
SQLObject/trunk/sqlobject/tests/test_decimal.py
Log:
Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2;
see http://mail.python.org/pipermail/python-dev/2008-March/078189.html
Modified: SQLObject/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2008-07-11 15:15:54 UTC (rev 3502)
+++ SQLObject/trunk/docs/News.txt 2008-07-11 15:29:51 UTC (rev 3503)
@@ -33,6 +33,11 @@
* DecimalStringCol - similar to DecimalCol but stores data as strings to
work around problems in some drivers and type affinity problem in SQLite.
+SQLObject 0.10.3
+================
+
+* A number of changes ported from `SQLObject 0.9.8`_.
+
SQLObject 0.10.2
================
@@ -119,6 +124,12 @@
* Under MySQL, PickleCol no longer used TEXT column types; the smallest
column is now BLOB - it is not possible to create TINYBLOB column.
+SQLObject 0.9.8
+===============
+
+* Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2;
+ see http://mail.python.org/pipermail/python-dev/2008-March/078189.html
+
SQLObject 0.9.7
===============
Modified: SQLObject/trunk/sqlobject/converters.py
===================================================================
--- SQLObject/trunk/sqlobject/converters.py 2008-07-11 15:15:54 UTC (rev 3502)
+++ SQLObject/trunk/sqlobject/converters.py 2008-07-11 15:29:51 UTC (rev 3503)
@@ -180,7 +180,8 @@
registerConverter(datetime.time, TimeConverter)
def DecimalConverter(value, db):
- return value.to_eng_string()
+ # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html
+ return str(value.to_eng_string()) # Convert to str to work around a bug in Python 2.5.2
registerConverter(Decimal, DecimalConverter)
Modified: SQLObject/trunk/sqlobject/tests/test_decimal.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_decimal.py 2008-07-11 15:15:54 UTC (rev 3502)
+++ SQLObject/trunk/sqlobject/tests/test_decimal.py 2008-07-11 15:29:51 UTC (rev 3503)
@@ -1,3 +1,5 @@
+# -*- coding: koi8-r -*-
+
from decimal import Decimal
from sqlobject import *
from sqlobject.tests.dbtest import *
@@ -7,25 +9,29 @@
########################################
class DecimalTable(SQLObject):
+ name = UnicodeCol(length=255)
col1 = DecimalCol(size=6, precision=4)
- col2 = DecimalStringCol(size=6, precision=4)
if supports('decimalColumn'):
def test_1_decimal():
setupClass(DecimalTable)
- d = DecimalTable(col1=21.12, col2='10.01')
+ d = DecimalTable(name='test', col1=21.12)
# psycopg2 returns float as Decimal
if isinstance(d.col1, Decimal):
assert d.col1 == Decimal("21.12")
else:
assert d.col1 == 21.12
- assert d.col2 == Decimal("10.01")
def test_2_decimal():
setupClass(DecimalTable)
- d = DecimalTable(col1=Decimal("21.12"), col2=Decimal('10.01'))
- if isinstance(d.col1, Decimal):
+ d = DecimalTable(name='test', col1=Decimal("21.12"))
+ assert d.col1 == Decimal("21.12")
+
+ # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html
+ if isinstance(Decimal(u'123').to_eng_string(), unicode): # a bug in Python 2.5.2
+ def test_3_unicode():
+ setupClass(DecimalTable)
+ d = DecimalTable(name='test', col1=Decimal(u"21.12"))
assert d.col1 == Decimal("21.12")
- else:
- assert d.col1 == 21.12
- assert d.col2 == Decimal("10.01")
+ d = DecimalTable(name=unicode('', 'koi8-r'), col1=Decimal(u"21.12"))
+ assert d.col1 == Decimal("21.12")
|