diff options
| author | Dmitry Shachnev <mitya57@gmail.com> | 2014-01-19 14:17:10 +0400 |
|---|---|---|
| committer | Dmitry Shachnev <mitya57@gmail.com> | 2014-01-19 14:17:10 +0400 |
| commit | 344417db950d6e816ab2efb21737c2bdf9d1ad53 (patch) | |
| tree | 97b00b55be0e28a73399acc0f80e21e6a4e24b28 /sphinx/environment.py | |
| parent | 59b355edaa4f17aff910bf2371526d5ce46fb648 (diff) | |
| download | sphinx-344417db950d6e816ab2efb21737c2bdf9d1ad53.tar.gz | |
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.
Diffstat (limited to 'sphinx/environment.py')
| -rw-r--r-- | sphinx/environment.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sphinx/environment.py b/sphinx/environment.py index a319ef3c..9b7aebdc 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -617,7 +617,7 @@ class BuildEnvironment: try: pub.publish() doctree = pub.document - except UnicodeError, err: + except UnicodeError as err: raise SphinxError(str(err)) # post-processing @@ -796,7 +796,7 @@ class BuildEnvironment: imgtype = imghdr.what(f) finally: f.close() - except (OSError, IOError), err: + except (OSError, IOError) as err: self.warn_node('image file %s not readable: %s' % (filename, err), node) if imgtype: @@ -907,7 +907,7 @@ class BuildEnvironment: longtitlenode = titlenode # explicit title set with title directive; use this only for # the <title> tag in HTML output - if document.has_key('title'): + if 'title' in document: longtitlenode = nodes.title() longtitlenode += nodes.Text(document['title']) # look for first section title and use that as the title @@ -1411,7 +1411,7 @@ class BuildEnvironment: for node in doctree.traverse(addnodes.only): try: ret = builder.tags.eval_condition(node['expr']) - except Exception, err: + except Exception as err: self.warn_node('exception while evaluating only ' 'directive expression: %s' % err, node) node.replace_self(node.children or nodes.comment()) @@ -1537,7 +1537,7 @@ class BuildEnvironment: add_entry(first, _('see also %s') % second, link=False) else: self.warn(fn, 'unknown index entry type %r' % type) - except ValueError, err: + except ValueError as err: self.warn(fn, str(err)) # sort the index entries; put all symbols at the front, even those |
