From fbae20030fc4674c57a632124dc15c85759e18bc Mon Sep 17 00:00:00 2001 From: "Lorenzo M. Catucci" Date: Tue, 19 Mar 2013 15:34:55 +0100 Subject: [PATCH] Truncated date input no longer raises ParseError --- colander/__init__.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/colander/__init__.py b/colander/__init__.py index 53973361..b4be7563 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -1407,13 +1407,8 @@ def deserialize(self, node, cstruct): result = iso8601.parse_date( cstruct, default_timezone=self.default_tzinfo) except (iso8601.ParseError, TypeError) as e: - try: - year, month, day = map(int, cstruct.split('-', 2)) - result = datetime.datetime(year, month, day, - tzinfo=self.default_tzinfo) - except Exception as e: - raise Invalid(node, _(self.err_template, - mapping={'val':cstruct, 'err':e})) + raise Invalid(node, _(self.err_template, + mapping={'val':cstruct, 'err':e})) return result class Date(SchemaType): @@ -1479,15 +1474,11 @@ def deserialize(self, node, cstruct): try: result = iso8601.parse_date(cstruct) result = result.date() - except (iso8601.ParseError, TypeError): - try: - year, month, day = map(int, cstruct.split('-', 2)) - result = datetime.date(year, month, day) - except Exception as e: - raise Invalid(node, - _(self.err_template, - mapping={'val':cstruct, 'err':e}) - ) + except (iso8601.ParseError, TypeError) as e: + raise Invalid(node, + _(self.err_template, + mapping={'val':cstruct, 'err':e}) + ) return result class Time(SchemaType):