From 304c9e71a26f0264bfd0b588e150bc6bf6461643 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 2 Sep 2010 14:02:19 +0800 Subject: [PATCH] Hand: Wrap Pot.end() section in exception handler If Hand.end() fails in that section, then something is seriously wrong with either action parsing or stack parsing. Throw a parse error in the hopes we can continue on. --- pyfpdb/Hand.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index ac8fc1f2..9f9d009d 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -1514,11 +1514,15 @@ class Pot(object): commitsall = sorted([(v,k) for (k,v) in self.committed.items() if v >0]) self.pots = [] - while len(commitsall) > 0: - commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders] - v1 = commitslive[0][0] - self.pots += [sum([min(v,v1) for (v,k) in commitsall])] - commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0] + try: + while len(commitsall) > 0: + commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders] + v1 = commitslive[0][0] + self.pots += [sum([min(v,v1) for (v,k) in commitsall])] + commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0] + except IndexError, e: + log.error(_("Pot.end(): Major failure while calculating pot: '%s'" % e)) + raise FpdbParseError(_("Pot.end(): Major failure while calculating pot: '%s'" % e)) # TODO: I think rake gets taken out of the pots. # so it goes: