[formfields] use support_args instead of catching type error avoid hiding other issues and making debugging difficult stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Jun 2011 15:50:26 +0200
branchstable
changeset 7572 a554010417ce
parent 7571 6386f802fbc6
child 7573 c8f8762c986d
[formfields] use support_args instead of catching type error avoid hiding other issues and making debugging difficult
web/formfields.py
--- a/web/formfields.py	Wed Jun 29 15:49:47 2011 +0200
+++ b/web/formfields.py	Wed Jun 29 15:50:26 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -386,12 +386,11 @@
         """
         assert self.choices is not None
         if callable(self.choices):
-            try:
-                if getattr(self.choices, 'im_self', None) is self:
-                    vocab = self.choices(form=form, **kwargs)
-                else:
-                    vocab = self.choices(form=form, field=self, **kwargs)
-            except TypeError:
+            if getattr(self.choices, 'im_self', None) is self:
+                vocab = self.choices(form=form, **kwargs)
+            elif support_args(self.choices, 'form', 'field'):
+                vocab = self.choices(form=form, field=self, **kwargs)
+            else:
                 try:
                     vocab = self.choices(form=form, **kwargs)
                     warn('[3.6]  %s: choices should now take '