From ae2d6d6f2560ff7f308b63b13f0b57a0b5f738a6 Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Thu, 18 Feb 2010 08:16:04 +0000
Subject: [PATCH] a KeyError here is rare: a try..except block is better than
 "look before leap"

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32724 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/XMLMatrix.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Type/XMLMatrix.py b/product/ERP5Type/XMLMatrix.py
index baf25ffec9..f3d66e47c7 100644
--- a/product/ERP5Type/XMLMatrix.py
+++ b/product/ERP5Type/XMLMatrix.py
@@ -496,9 +496,9 @@ class XMLMatrix(Folder):
 
       base_item = self.index[base_id]
       for i, my_id in enumerate(kw):
-        if base_item[i].has_key(my_id):
+        try:
           cell_id += '_%s' % base_item[i][my_id]
-        else:
+        except KeyError:
           raise KeyError, 'Invalid key: %s' % str(kw)
 
       cell = self.get(cell_id)
-- 
2.30.9