diff --git a/formencode/schema.py b/formencode/schema.py index 967e5a8b..cb5ff7b6 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -193,7 +193,7 @@ def _to_python(self, value_dict, state): state.key = name try: new[name] = validator.to_python(value, state) - except Invalid as e: + except Invalid, e: errors[name] = e for name in unused: @@ -216,7 +216,7 @@ def _to_python(self, value_dict, state): state.key = name try: new[name] = validator.to_python(self.if_key_missing, state) - except Invalid as e: + except Invalid, e: errors[name] = e else: new[name] = validator.if_missing @@ -229,7 +229,7 @@ def _to_python(self, value_dict, state): continue try: validator.validate_partial(value_dict, state) - except Invalid as e: + except Invalid, e: sub_errors = e.unpack_errors() if not isinstance(sub_errors, dict): # Can't do anything here @@ -285,7 +285,7 @@ def _from_python(self, value_dict, state): state.key = name try: new[name] = self.fields[name].from_python(value, state) - except Invalid as e: + except Invalid, e: errors[name] = e del __traceback_info__ @@ -296,7 +296,7 @@ def _from_python(self, value_dict, state): state.key = name try: new[name] = validator.from_python(None, state) - except Invalid as e: + except Invalid, e: errors[name] = e if errors: diff --git a/tests/test_schema.py b/tests/test_schema.py index ea60ea94..4bc756be 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -75,7 +75,7 @@ def test(self): print repr(self.raw_input) try: print repr(self.schema.to_python(self.input)) - except Invalid as e: + except Invalid, e: actual = e.unpack_errors() assert actual == self.output else: @@ -175,11 +175,11 @@ def test_multiple_chained_validators_errors(): s = ChainedTest() try: s.to_python({'a':'1', 'a_confirm':'2', 'b':'3', 'b_confirm':'4'}) - except Invalid as e: + except Invalid, e: assert 'a_confirm' in e.error_dict and 'b_confirm' in e.error_dict try: s.to_python({}) - except Invalid as e: + except Invalid: pass else: assert False @@ -271,7 +271,7 @@ def test_Schema_with_input_missing(self): # try: self.schema.to_python({}) - except Invalid as exc: + except Invalid, exc: error_message = exc.error_dict['agree'].msg assert self.not_empty_messages['missing'] == error_message, \ error_message