Changeset 1951
- Timestamp:
- 04/26/08 18:40:30
- Files:
-
- trunk/cherrypy/__init__.py (modified) (1 diff)
- trunk/cherrypy/_cptools.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1938 r1951 136 136 delattr(cls, name) 137 137 138 # Get an inspect-style docstring if possible (usually so). 139 val = dct[name] 140 try: 141 import inspect 142 val = inspect.getdoc(property(doc=val)).strip() 143 except: 144 pass 145 146 # Indent the docstring. 147 val = '\n'.join([' ' + line.rstrip() 148 for line in val.split('\n')]) 138 # Make a uniformly-indented docstring from it. 139 val = '\n'.join([' ' + line.strip() 140 for line in dct[name].split('\n')]) 149 141 150 142 # Get the default value. trunk/cherrypy/_cptools.py
r1811 r1951 24 24 25 25 import cherrypy 26 27 28 def _getargs(func): 29 """Return the names of all static arguments to the given function.""" 30 # Use this instead of importing inspect for less mem overhead. 31 import types 32 if isinstance(func, types.MethodType): 33 func = func.im_func 34 co = func.func_code 35 return co.co_varnames[:co.co_argcount] 26 36 27 37 … … 45 55 """Copy func parameter names to obj attributes.""" 46 56 try: 47 import inspect 48 for arg in inspect.getargspec(self.callable)[0]: 57 for arg in _getargs(self.callable): 49 58 setattr(self, arg, None) 50 except (ImportError, AttributeError): 51 pass 52 except TypeError: 59 except (TypeError, AttributeError): 53 60 if hasattr(self.callable, "__call__"): 54 for arg in inspect.getargspec(self.callable.__call__)[0]:61 for arg in _getargs(self.callable.__call__): 55 62 setattr(self, arg, None) 56 63 # IronPython 1.0 raises NotImplementedError because … … 59 66 except NotImplementedError: 60 67 pass 61 # IronPython 1B1 may raise that error in some cases 62 # but if we trap it here it doesn't prevent CP from 63 # working 68 # IronPython 1B1 may raise IndexError in some cases, 69 # but if we trap it here it doesn't prevent CP from working. 64 70 except IndexError: 65 71 pass

