[py3k] except as

Requires python >= 2.6.

authorRémi Cardona <remi.cardona@free.fr>
changeset45a8c70803be
branchdefault
phasedraft
hiddenyes
parent revision#12c234bf5986 [py3k] import range from six.moves
child revision#af4a07cbe03b [py3k] print function
files modified by this revision
examples/menza2.py
propagation.py
test/test_propagation.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@free.fr>
# Date 1423989987 -3600
# Sun Feb 15 09:46:27 2015 +0100
# Node ID 45a8c70803be99fea942f1d71ecbcdac32528333
# Parent 12c234bf59860a487f89e8ba481def87e4cd2427
[py3k] except as

Requires python >= 2.6.

diff --git a/examples/menza2.py b/examples/menza2.py
@@ -36,11 +36,11 @@
1                  s = str(v)
2                  for d in ('0','1','2','3','4','5','6','7','8','9'):
3                      if s.count(d) not in (0,1):
4                          domain.removeValue(v)
5                          break
6 -        except ConsistencyFailure, e:
7 +        except ConsistencyFailure as e:
8              raise ConsistencyFailure('inconsistency while applying %s'%repr(self))
9          return 1
10 
11      def __repr__(self):
12          return '<DistinctDigits>'
diff --git a/propagation.py b/propagation.py
@@ -290,11 +290,11 @@
13              self.printer( strftime('%H:%M:%S'),)
14              self.printer( '*** [%d] Solve called with repository' % recursion_level,)
15              repository.display_vars()
16          try:
17              foundSolution = repository.consistency(verbose, custom_printer=self.printer)
18 -        except ConsistencyFailure, exc:
19 +        except ConsistencyFailure as exc:
20              if verbose:
21                  self.printer( strftime('%H:%M:%S'), exc)
22          else:
23              if foundSolution:
24                  solution = {}
diff --git a/test/test_propagation.py b/test/test_propagation.py
@@ -41,11 +41,11 @@
25                      self.repo.addConstraint(fd.make_expression((v1, v2),
26                                                             '%s < %s'%(v1, v2)))
27          try:
28              try:
29                  self.repo.vcg_draw('toto.vcg')
30 -            except IOError, exc:
31 +            except IOError as exc:
32                  self.fail('This test cannot run in the testing environment'
33                            'because I cannot write the file.\n'
34                            'The error message was: \n%s' % exc)
35          finally:
36              os.unlink('toto.vcg')