From f180c6a19178dd40a5ff5668a4ee38796545560a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 1 Oct 2012 22:51:48 -0400 Subject: [PATCH] - Work around a regression in Python 3.3 for ``colander.Decimal`` when it's used with a ``quant`` argument but without a ``rounding`` argument. See https://github.com/Pylons/colander/issues/66 - Add Python 3.3 to tox configuration and use newer tox testing regime (setup.py dev). Closes #66 --- CHANGES.txt | 16 ++++++++++++++++ colander/__init__.py | 14 +++++++++----- tox.ini | 13 +++---------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 939bad2..9ca578a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,19 @@ +Next release +------------ + +Bug Fixes +~~~~~~~~~ + +- Work around a regression in Python 3.3 for ``colander.Decimal`` when it's + used with a ``quant`` argument but without a ``rounding`` argument. + See https://github.com/Pylons/colander/issues/66 + +Features +~~~~~~~~ + +- Add Python 3.3 to tox configuration and use newer tox testing regime + (setup.py dev). + 0.9.9 (2012-09-24) ------------------ diff --git a/colander/__init__.py b/colander/__init__.py index bf947eb..7686d14 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -1086,10 +1086,11 @@ class Decimal(Number): returned. The Decimal constructor takes two optional arguments, ``quant`` and - ``rounding``. If supplied, ``quant`` should be a string. If supplied, - ``rounding`` should be one of the Python ``decimal`` module rounding - options (e.g. ``decimal.ROUND_UP``, ``decimal.ROUND_DOWN``, etc). The - serialized and deserialized result will be quantized and rounded via + ``rounding``. If supplied, ``quant`` should be a string, + (e.g. ``1.00``). If supplied, ``rounding`` should be one of the Python + ``decimal`` module rounding options (e.g. ``decimal.ROUND_UP``, + ``decimal.ROUND_DOWN``, etc). The serialized and deserialized result + will be quantized and rounded via ``result.quantize(decimal.Decimal(quant), rounding)``. ``rounding`` is ignored if ``quant`` is not supplied. @@ -1106,7 +1107,10 @@ class Decimal(Number): def num(self, val): result = decimal.Decimal(str(val)) if self.quant is not None: - result = result.quantize(self.quant, self.rounding) + if self.rounding is None: + result = result.quantize(self.quant) + else: + result = result.quantize(self.quant, self.rounding) return result class Money(Decimal): diff --git a/tox.ini b/tox.ini index 89048f7..b2df534 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,11 @@ [tox] envlist = - py26,py27,py32,pypy,cover + py26,py27,py32,py33,pypy,cover [testenv] commands = - python setup.py test -q + python setup.py dev + python -Wd setup.py test -q [testenv:cover] basepython = @@ -12,12 +13,4 @@ basepython = commands = python setup.py nosetests --with-xunit --with-xcoverage deps = - nose - coverage==3.4 nosexcover - -# we separate coverage into its own testenv because a) "last run wins" wrt -# cobertura jenkins reporting and b) pypy and jython can't handle any -# combination of versions of coverage and nosexcover that i can find. -# coverage==3.4 is required by nosexcover -