From ce2185ce279664e54ba22b14663091abc5a3a8f2 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 19 Jan 2014 14:17:10 +0400 Subject: Modernize the code now that Python 2.5 is no longer supported - Use print function instead of print statement; - Use new exception handling; - Use in operator instead of has_key(); - Do not use tuple arguments in functions; - Other miscellaneous improvements. This is based on output of `futurize --stage1`, with some manual corrections. --- sphinx/ext/autodoc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sphinx/ext/autodoc.py') diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 571f36cbe..791961b90 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -411,7 +411,7 @@ class Documenter(object): # try to introspect the signature try: args = self.format_args() - except Exception, err: + except Exception as err: self.directive.warn('error while formatting arguments for ' '%s: %s' % (self.fullname, err)) args = None @@ -731,7 +731,7 @@ class Documenter(object): # parse right now, to get PycodeErrors on parsing (results will # be cached anyway) self.analyzer.find_attr_docs() - except PycodeError, err: + except PycodeError as err: self.env.app.debug('[autodoc] module analyzer failed: %s', err) # no source file -- e.g. for builtin and C modules self.analyzer = None @@ -1197,7 +1197,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): ret = ClassLevelDocumenter.import_object(self) if isinstance(self.object, classmethod) or \ (isinstance(self.object, MethodType) and - self.object.im_self is not None): + self.object.__self__ is not None): self.directivetype = 'classmethod' # document class and static members before ordinary ones self.member_order = self.member_order - 1 @@ -1389,7 +1389,7 @@ class AutoDirective(Directive): try: self.genopt = Options(assemble_option_dict( self.options.items(), doc_class.option_spec)) - except (KeyError, ValueError, TypeError), err: + except (KeyError, ValueError, TypeError) as err: # an option is either unknown or has a wrong type msg = self.reporter.error('An option to %s is either unknown or ' 'has an invalid value: %s' % (self.name, err), -- cgit v1.2.1