[Erp5-report] r32724 nicolas.dumazet - /erp5/trunk/products/ERP5Type/XMLMatrix.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 18 09:16:04 CET 2010


Author: nicolas.dumazet
Date: Thu Feb 18 09:16:04 2010
New Revision: 32724

URL: http://svn.erp5.org?rev=32724&view=rev
Log:
a KeyError here is rare: a try..except block is better than "look before leap"

Modified:
    erp5/trunk/products/ERP5Type/XMLMatrix.py

Modified: erp5/trunk/products/ERP5Type/XMLMatrix.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/XMLMatrix.py?rev=32724&r1=32723&r2=32724&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/XMLMatrix.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/XMLMatrix.py [utf8] Thu Feb 18 09:16:04 2010
@@ -496,9 +496,9 @@
 
       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)




More information about the Erp5-report mailing list