|
From: <mi...@us...> - 2019-08-26 12:12:04
|
Revision: 8347
http://sourceforge.net/p/docutils/code/8347
Author: milde
Date: 2019-08-26 12:12:02 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Switch to 'except foo as bar' syntax
This is the only form supported in Python 3.x.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/body.py
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_publisher.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/core.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -219,10 +219,10 @@
self.apply_transforms()
output = self.writer.write(self.document, self.destination)
self.writer.assemble_parts()
- except SystemExit, error:
+ except SystemExit as error:
exit = 1
exit_status = error.code
- except Exception, error:
+ except Exception as error:
if not self.settings: # exception too early to report nicely
raise
if self.settings.traceback: # Propagate exceptions?
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -62,7 +62,7 @@
"""
try:
new_settings = parser.get_config_file_settings(value)
- except ValueError, error:
+ except ValueError as error:
parser.error(error)
parser.values.update(new_settings, parser)
@@ -346,7 +346,7 @@
value = getattr(values, setting)
try:
new_value = self.validator(setting, value, parser)
- except Exception, error:
+ except Exception as error:
raise (optparse.OptionValueError(
'Error in option "%s":\n %s'
% (opt, ErrorString(error))),
@@ -605,7 +605,7 @@
if read_config_files and not self.defaults['_disable_config']:
try:
config_settings = self.get_standard_config_settings()
- except ValueError, error:
+ except ValueError as error:
self.error(SafeString(error))
self.set_defaults_from_dict(config_settings.__dict__)
@@ -826,7 +826,7 @@
new_value = option.validator(
setting, value, option_parser,
config_parser=self, config_section=section)
- except Exception, error:
+ except Exception as error:
raise (ValueError(
'Error in config file "%s", section "[%s]":\n'
' %s\n'
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/io.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -114,7 +114,7 @@
self.successful_encoding = enc
# Return decoded, removing BOMs.
return decoded.replace(u'\ufeff', u'')
- except (UnicodeError, LookupError), err:
+ except (UnicodeError, LookupError) as err:
error = err # in Python 3, the <exception instance> is
# local to the except clause
raise UnicodeError(
@@ -244,7 +244,7 @@
try:
self.source = open(source_path, mode, **kwargs)
- except IOError, error:
+ except IOError as error:
raise InputError(error.errno, error.strerror, source_path)
else:
self.source = sys.stdin
@@ -272,7 +272,7 @@
data = b'\n'.join(data.splitlines()) + b'\n'
else:
data = self.source.read()
- except (UnicodeError, LookupError), err: # (in Py3k read() decodes)
+ except (UnicodeError, LookupError) as err: # (in Py3k read() decodes)
if not self.encoding and self.source_path:
# re-read in binary mode and decode with heuristics
b_source = open(self.source_path, 'rb')
@@ -362,7 +362,7 @@
kwargs = {}
try:
self.destination = open(self.destination_path, self.mode, **kwargs)
- except IOError, error:
+ except IOError as error:
raise OutputError(error.errno, error.strerror,
self.destination_path)
self.opened = True
@@ -384,7 +384,7 @@
try:
self.destination.write(data)
- except TypeError, e:
+ except TypeError as e:
if sys.version_info >= (3,0) and isinstance(data, bytes):
try:
self.destination.buffer.write(data)
@@ -397,7 +397,7 @@
self.destination.encoding, self.encoding))
else:
raise e
- except (UnicodeError, LookupError), err:
+ except (UnicodeError, LookupError) as err:
raise UnicodeError(
'Unable to encode output data. output-encoding is: '
'%s.\n(%s)' % (self.encoding, ErrorString(err)))
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -86,7 +86,7 @@
canonicalname = None
try:
canonicalname = language_module.directives[normname]
- except AttributeError, error:
+ except AttributeError as error:
msg_text.append('Problem retrieving directive entry from language '
'module %r: %s.' % (language_module, error))
except KeyError:
@@ -113,7 +113,7 @@
return None, messages
try:
module = __import__(modulename, globals(), locals(), level=1)
- except ImportError, detail:
+ except ImportError as detail:
messages.append(document.reporter.error(
'Error importing directive module "%s" (directive "%s"):\n%s'
% (modulename, directive_name, detail),
@@ -309,7 +309,7 @@
return unichr(int(value, 16))
else: # other text
return code
- except OverflowError, detail:
+ except OverflowError as detail:
raise ValueError('code too large (%s)' % detail)
def single_char_or_unicode(argument):
Modified: trunk/docutils/docutils/parsers/rst/directives/body.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/body.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/body.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -147,7 +147,7 @@
try:
tokens = Lexer(u'\n'.join(self.content), language,
self.state.document.settings.syntax_highlight)
- except LexerError, error:
+ except LexerError as error:
raise self.warning(error)
if 'number-lines' in self.options:
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -55,7 +55,7 @@
try:
attname, val = utils.extract_name_value(token)[0]
node[attname.lower()] = val
- except utils.NameValueError, detail:
+ except utils.NameValueError as detail:
line = self.state_machine.line
msg = self.reporter.error(
'Error parsing meta tag attribute "%s": %s.'
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -73,12 +73,12 @@
include_file = io.FileInput(source_path=path,
encoding=encoding,
error_handler=e_handler)
- except UnicodeEncodeError, error:
+ except UnicodeEncodeError as error:
raise self.severe(u'Problems with "%s" directive path:\n'
'Cannot encode input file path "%s" '
'(wrong locale?).' %
(self.name, SafeString(path)))
- except IOError, error:
+ except IOError as error:
raise self.severe(u'Problems with "%s" directive path:\n%s.' %
(self.name, ErrorString(error)))
startline = self.options.get('start-line', None)
@@ -89,7 +89,7 @@
rawtext = ''.join(lines[startline:endline])
else:
rawtext = include_file.read()
- except UnicodeError, error:
+ except UnicodeError as error:
raise self.severe(u'Problem with "%s" directive:\n%s' %
(self.name, ErrorString(error)))
# start-after/end-before: no restrictions on newlines in match-text,
@@ -213,12 +213,12 @@
# TODO: currently, raw input files are recorded as
# dependencies even if not used for the chosen output format.
self.state.document.settings.record_dependencies.add(path)
- except IOError, error:
+ except IOError as error:
raise self.severe(u'Problems with "%s" directive path:\n%s.'
% (self.name, ErrorString(error)))
try:
text = raw_file.read()
- except UnicodeError, error:
+ except UnicodeError as error:
raise self.severe(u'Problem with "%s" directive:\n%s'
% (self.name, ErrorString(error)))
attributes['source'] = path
@@ -230,7 +230,7 @@
import urllib2
try:
raw_text = urllib2.urlopen(source).read()
- except (urllib2.URLError, IOError, OSError), error:
+ except (urllib2.URLError, IOError, OSError) as error:
raise self.severe(u'Problems with "%s" directive URL "%s":\n%s.'
% (self.name, self.options['url'], ErrorString(error)))
raw_file = io.StringInput(source=raw_text, source_path=source,
@@ -238,7 +238,7 @@
error_handler=e_handler)
try:
text = raw_file.read()
- except UnicodeError, error:
+ except UnicodeError as error:
raise self.severe(u'Problem with "%s" directive:\n%s'
% (self.name, ErrorString(error)))
attributes['source'] = source
@@ -320,7 +320,7 @@
for code in codes:
try:
decoded = directives.unicode_code(code)
- except ValueError, error:
+ except ValueError as error:
raise self.error(u'Invalid character code: %s\n%s'
% (code, ErrorString(error)))
element += nodes.Text(decoded)
@@ -406,7 +406,7 @@
self.state.parse_directive_block(
self.content[1:], self.content_offset, converted_role,
option_presets={}))
- except states.MarkupError, detail:
+ except states.MarkupError as detail:
error = self.state_machine.reporter.error(
'Error in "%s" directive:\n%s.' % (self.name, detail),
nodes.literal_block(self.block_text, self.block_text),
@@ -415,7 +415,7 @@
if 'class' not in options:
try:
options['class'] = directives.class_option(new_role_name)
- except ValueError, detail:
+ except ValueError as detail:
error = self.state_machine.reporter.error(
u'Invalid argument for "%s" directive:\n%s.'
% (self.name, SafeString(detail)), nodes.literal_block(
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -259,9 +259,9 @@
col_widths = self.get_column_widths(max_cols)
self.extend_short_rows_with_empty_cells(max_cols,
(table_head, table_body))
- except SystemMessagePropagation, detail:
+ except SystemMessagePropagation as detail:
return [detail.args[0]]
- except csv.Error, detail:
+ except csv.Error as detail:
message = str(detail)
if sys.version_info < (3,) and '1-character string' in message:
message += '\nwith Python 2.x this must be an ASCII character.'
@@ -320,7 +320,7 @@
encoding=encoding,
error_handler=error_handler)
csv_data = csv_file.read().splitlines()
- except IOError, error:
+ except IOError as error:
severe = self.state_machine.reporter.severe(
u'Problems with "%s" directive path:\n%s.'
% (self.name, SafeString(error)),
@@ -336,7 +336,7 @@
source = self.options['url']
try:
csv_text = urllib2.urlopen(source).read()
- except (urllib2.URLError, IOError, OSError, ValueError), error:
+ except (urllib2.URLError, IOError, OSError, ValueError) as error:
severe = self.state_machine.reporter.severe(
'Problems with "%s" directive URL "%s":\n%s.'
% (self.name, self.options['url'], SafeString(error)),
@@ -424,7 +424,7 @@
header_rows = self.options.get('header-rows', 0)
stub_columns = self.options.get('stub-columns', 0)
self.check_table_dimensions(table_data, header_rows, stub_columns)
- except SystemMessagePropagation, detail:
+ except SystemMessagePropagation as detail:
return [detail.args[0]]
table_node = self.build_table_from_list(table_data, col_widths,
header_rows, stub_columns)
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -109,7 +109,7 @@
canonicalname = None
try:
canonicalname = language_module.roles[normname]
- except AttributeError, error:
+ except AttributeError as error:
msg_text.append('Problem retrieving role entry from language '
'module %r: %s.' % (language_module, error))
except KeyError:
@@ -333,7 +333,7 @@
try:
tokens = Lexer(utils.unescape(text, True), language,
inliner.document.settings.syntax_highlight)
- except LexerError, error:
+ except LexerError as error:
msg = inliner.reporter.warning(error)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -1495,7 +1495,7 @@
(optionlist.source, optionlist.line) = self.state_machine.get_source_and_line()
try:
listitem, blank_finish = self.option_list_item(match)
- except MarkupError, error:
+ except MarkupError as error:
# This shouldn't happen; pattern won't match.
msg = self.reporter.error(u'Invalid option list marker: %s' %
error)
@@ -1684,7 +1684,7 @@
+ 1)
table = self.build_table(tabledata, tableline)
nodelist = [table] + messages
- except tableparser.TableMarkupError, err:
+ except tableparser.TableMarkupError as err:
nodelist = self.malformed_table(block, ' '.join(err.args),
offset=err.offset) + messages
else:
@@ -1696,7 +1696,7 @@
blank_finish = 1
try:
block = self.state_machine.get_text_block(flush_left=True)
- except statemachine.UnexpectedIndentationError, err:
+ except statemachine.UnexpectedIndentationError as err:
block, src, srcline = err.args
messages.append(self.reporter.error('Unexpected indentation.',
source=src, line=srcline))
@@ -2133,7 +2133,7 @@
arguments, options, content, content_offset = (
self.parse_directive_block(indented, line_offset,
directive, option_presets))
- except MarkupError, detail:
+ except MarkupError as detail:
error = self.reporter.error(
'Error in "%s" directive:\n%s.' % (type_name,
' '.join(detail.args)),
@@ -2144,7 +2144,7 @@
content_offset, block_text, self, self.state_machine)
try:
result = directive_instance.run()
- except docutils.parsers.rst.DirectiveError, error:
+ except docutils.parsers.rst.DirectiveError as error:
msg_node = self.reporter.system_message(error.level, error.msg,
line=lineno)
msg_node += nodes.literal_block(block_text, block_text)
@@ -2261,11 +2261,11 @@
return 0, 'invalid option block'
try:
options = utils.extract_extension_options(node, option_spec)
- except KeyError, detail:
+ except KeyError as detail:
return 0, ('unknown option: "%s"' % detail.args[0])
- except (ValueError, TypeError), detail:
+ except (ValueError, TypeError) as detail:
return 0, ('invalid option value: %s' % ' '.join(detail.args))
- except utils.ExtensionOptionError, detail:
+ except utils.ExtensionOptionError as detail:
return 0, ('invalid option data: %s' % ' '.join(detail.args))
if blank_finish:
return 1, options
@@ -2352,7 +2352,7 @@
if expmatch:
try:
return method(self, expmatch)
- except MarkupError, error:
+ except MarkupError as error:
lineno = self.state_machine.abs_line_number()
message = ' '.join(error.args)
errors.append(self.reporter.warning(message, line=lineno))
@@ -2775,7 +2775,7 @@
msg = None
try:
block = self.state_machine.get_text_block(flush_left=True)
- except statemachine.UnexpectedIndentationError, err:
+ except statemachine.UnexpectedIndentationError as err:
block, src, srcline = err.args
msg = self.reporter.error('Unexpected indentation.',
source=src, line=srcline)
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -248,7 +248,7 @@
break
else:
results.extend(result)
- except TransitionCorrection, exception:
+ except TransitionCorrection as exception:
self.previous_line() # back up for another try
transitions = (exception.args[0],)
if self.debug:
@@ -257,7 +257,7 @@
'state "%s", transition %s.'
% (state.__class__.__name__, transitions[0])), file=self._stderr)
continue
- except StateCorrection, exception:
+ except StateCorrection as exception:
self.previous_line() # back up for another try
next_state = exception.args[0]
if len(exception.args) == 1:
@@ -413,7 +413,7 @@
flush_left)
self.next_line(len(block) - 1)
return block
- except UnexpectedIndentationError, err:
+ except UnexpectedIndentationError as err:
block = err.args[0]
self.next_line(len(block) - 1) # advance to last line of block
raise
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -326,7 +326,7 @@
raise DuplicateOptionError('duplicate option "%s"' % name)
try:
options[name] = convertor(value)
- except (ValueError, TypeError), detail:
+ except (ValueError, TypeError) as detail:
raise detail.__class__('(option: "%s"; value: %r)\n%s'
% (name, value, ' '.join(detail.args)))
return options
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -49,7 +49,7 @@
# locale.getpreferredencoding([do_setlocale=True|False])
# has side-effects | might return a wrong guess.
# (cf. Update 1 in http://stackoverflow.com/questions/4082645/using-python-2-xs-locale-module-to-format-numbers-and-currency)
- except ValueError, error: # OS X may set UTF-8 without language code
+ except ValueError as error: # OS X may set UTF-8 without language code
# see http://bugs.python.org/issue18378
# and https://sourceforge.net/p/docutils/bugs/298/
if "unknown locale: UTF-8" in error.args:
@@ -113,7 +113,7 @@
if isinstance(self.data, EnvironmentError):
u = u.replace(": u'", ": '") # normalize filename quoting
return u
- except UnicodeError, error: # catch ..Encode.. and ..Decode.. errors
+ except UnicodeError as error: # catch ..Encode.. and ..Decode.. errors
if isinstance(self.data, EnvironmentError):
return u"[Errno %s] %s: '%s'" % (self.data.errno,
SafeString(self.data.strerror, self.encoding,
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -302,7 +302,7 @@
content = io.FileInput(source_path=path,
encoding='utf-8').read()
self.settings.record_dependencies.add(path)
- except IOError, err:
+ except IOError as err:
msg = u"Cannot embed stylesheet '%s': %s." % (
path, SafeString(err.strerror))
self.document.reporter.error(msg)
@@ -1159,7 +1159,7 @@
'with math-output "MathML"')
except OSError:
raise OSError('is "latexmlmath" in your PATH?')
- except SyntaxError, err:
+ except SyntaxError as err:
err_node = self.document.reporter.error(err, base_node=node)
self.visit_system_message(err_node)
self.body.append(self.starttag(node, 'p'))
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -173,7 +173,7 @@
xml_string = xml_string.encode('utf8')
try:
self.xmlparser.parse(StringIO(xml_string))
- except xml.sax._exceptions.SAXParseException, error:
+ except xml.sax._exceptions.SAXParseException as error:
col_num = self.the_handle.locator.getColumnNumber()
line_num = self.the_handle.locator.getLineNumber()
srcline = node.line
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -1416,7 +1416,7 @@
content = io.FileInput(source_path=path,
encoding='utf-8').read()
self.settings.record_dependencies.add(path)
- except IOError, err:
+ except IOError as err:
msg = u"Cannot embed stylesheet '%s':\n %s." % (
path, SafeString(err.strerror))
self.document.reporter.error(msg)
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -230,7 +230,7 @@
output = '\n'.join(output.splitlines())
try:
self.assertEqual(output, expected)
- except AssertionError, error:
+ except AssertionError as error:
print('\n%s\ninput:' % (self,), file=sys.stderr)
print(input, file=sys.stderr)
try:
@@ -543,7 +543,7 @@
self.parser.find_head_body_sep()
self.parser.parse_table()
output = self.parser.cells
- except Exception, details:
+ except Exception as details:
output = '%s: %s' % (details.__class__.__name__, details)
self.compare_output(self.input, pformat(output) + '\n',
pformat(self.expected) + '\n')
@@ -552,7 +552,7 @@
try:
output = self.parser.parse(StringList(string2lines(self.input),
'test data'))
- except Exception, details:
+ except Exception as details:
output = '%s: %s' % (details.__class__.__name__, details)
self.compare_output(self.input, pformat(output) + '\n',
pformat(self.expected) + '\n')
@@ -865,7 +865,7 @@
"""
try:
func(*args, **kwds)
- except Exception, detail:
+ except Exception as detail:
return (detail, detail.args,
'%s: %s' % (detail.__class__.__name__, detail))
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -64,7 +64,7 @@
debug =1
if len(args) != 0:
usageExit("No command-line arguments supported yet.")
- except getopt.error, msg:
+ except getopt.error as msg:
usageExit(msg)
def loadTestModules(path, name='', packages=None):
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -19,7 +19,7 @@
try:
something
- except IOError, error:
+ except IOError as error:
print('Found %s' % error)
unless the minimal required Python version has this problem fixed.
@@ -219,29 +219,29 @@
us = u'\xfc'
try:
open(b'\xfc')
- except IOError, e: # in Python 3 the name for the exception instance
+ except IOError as e: # in Python 3 the name for the exception instance
bioe = e # is local to the except clause
try:
open(u'\xfc')
- except IOError, e:
+ except IOError as e:
uioe = e
except UnicodeEncodeError:
try:
open(u'\xfc'.encode(sys.getfilesystemencoding(), 'replace'))
- except IOError, e:
+ except IOError as e:
uioe = e
try:
os.chdir(b'\xfc')
- except OSError, e:
+ except OSError as e:
bose = e
try:
os.chdir(u'\xfc')
- except OSError, e:
+ except OSError as e:
uose = e
except UnicodeEncodeError:
try:
os.chdir(u'\xfc'.encode(sys.getfilesystemencoding(), 'replace'))
- except OSError, e:
+ except OSError as e:
uose = e
# wrapped test data:
wbioe = SafeString(bioe)
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/test_language.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -144,7 +144,7 @@
func, msg = directives.directive(d, module, None)
if not func:
failures.append('"%s": unknown directive' % d)
- except Exception, error:
+ except Exception as error:
failures.append('"%s": %s' % (d, error))
inverted = self._invert(module.directives)
canonical = directives._directive_registry.keys()
@@ -179,7 +179,7 @@
method = roles._role_registry[d]
#if not method:
# failures.append('"%s": unknown role' % d)
- except KeyError, error:
+ except KeyError as error:
failures.append('"%s": %s' % (d, error))
inverted = self._invert(module.roles)
canonical = roles._role_registry.keys()
Modified: trunk/docutils/test/test_publisher.py
===================================================================
--- trunk/docutils/test/test_publisher.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/test_publisher.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -65,7 +65,7 @@
try:
core.publish_cmdline(argv=['nonexisting/path'],
settings_overrides={'traceback': True})
- except IOError, e:
+ except IOError as e:
self.assertTrue(isinstance(e, io.InputError))
@@ -74,7 +74,7 @@
try:
core.publish_cmdline(argv=['data/include.txt', 'nonexisting/path'],
settings_overrides={'traceback': True})
- except IOError, e:
+ except IOError as e:
self.assertTrue(isinstance(e, io.OutputError))
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/test_utils.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -85,7 +85,7 @@
and hence fails with unicode message"""
try:
raise Exception(u'mesidʒ')
- except Exception, err:
+ except Exception as err:
sw = self.reporter.system_message(0, err)
self.assertEqual(sw.pformat(), u"""\
<system_message level="0" source="test data" type="DEBUG">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|