# HG changeset patch # User RĂ©mi Cardona # Date 1442928325 -7200 # Node ID 8a2ec43fcf44862e86db4aed40d2ea3433ce7131 # Parent ec0f96cd7a1871c63fa72f2923d5ac7d6c16abc5 [py3k] use inspect module to get a function's arguments diff -r ec0f96cd7a18 -r 8a2ec43fcf44 devtools/fill.py --- a/devtools/fill.py Fri Sep 18 17:58:30 2015 +0200 +++ b/devtools/fill.py Tue Sep 22 15:25:25 2015 +0200 @@ -26,6 +26,7 @@ from copy import deepcopy from datetime import datetime, date, time, timedelta from decimal import Decimal +import inspect from six import text_type, add_metaclass from six.moves import range @@ -258,7 +259,7 @@ for attrname, attrvalue in classdict.items(): if callable(attrvalue): if attrname.startswith('generate_') and \ - attrvalue.func_code.co_argcount < 2: + len(inspect.getargspec(attrvalue).args) < 2: raise TypeError('generate_xxx must accept at least 1 argument') setattr(_ValueGenerator, attrname, attrvalue) return type.__new__(mcs, name, bases, classdict) diff -r ec0f96cd7a18 -r 8a2ec43fcf44 web/views/forms.py --- a/web/views/forms.py Fri Sep 18 17:58:30 2015 +0200 +++ b/web/views/forms.py Tue Sep 22 15:25:25 2015 +0200 @@ -48,6 +48,7 @@ from warnings import warn import time +import inspect from logilab.common import dictattr, tempattr from logilab.common.decorators import iclassmethod, cached @@ -257,7 +258,7 @@ editedfields = self._cw.form['_cw_fields'] except KeyError: raise RequestError(self._cw._('no edited fields specified')) - entityform = entity and self.field_by_name.im_func.func_code.co_argcount == 4 # XXX + entityform = entity and len(inspect.getargspec(self.field_by_name)) == 4 # XXX for editedfield in splitstrip(editedfields): try: name, role = editedfield.split('-')