|
From: <mi...@us...> - 2019-08-26 16:42:26
|
Revision: 8353
http://sourceforge.net/p/docutils/code/8353
Author: milde
Date: 2019-08-26 16:42:23 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Replace deprecated form of raising exception
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/utils/roman.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/package_unittest.py
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -74,9 +74,8 @@
try:
codecs.lookup(value)
except LookupError:
- raise (LookupError('setting "%s": unknown encoding: "%s"'
- % (setting, value)),
- None, sys.exc_info()[2])
+ raise LookupError('setting "%s": unknown encoding: "%s"'
+ % (setting, value))
return value
def validate_encoding_error_handler(setting, value, option_parser,
@@ -84,12 +83,11 @@
try:
codecs.lookup_error(value)
except LookupError:
- raise (LookupError(
+ raise LookupError(
'unknown encoding error handler: "%s" (choices: '
'"strict", "ignore", "replace", "backslashreplace", '
'"xmlcharrefreplace", and possibly others; see documentation for '
- 'the Python ``codecs`` module)' % value),
- None, sys.exc_info()[2])
+ 'the Python ``codecs`` module)' % value)
return value
def validate_encoding_and_error_handler(
@@ -125,8 +123,7 @@
try:
return option_parser.booleans[value.strip().lower()]
except KeyError:
- raise (LookupError('unknown boolean value: "%s"' % value),
- None, sys.exc_info()[2])
+ raise LookupError('unknown boolean value: "%s"' % value)
def validate_ternary(setting, value, option_parser,
config_parser=None, config_section=None):
@@ -157,8 +154,7 @@
try:
return option_parser.thresholds[value.lower()]
except (KeyError, AttributeError):
- raise (LookupError('unknown threshold: %r.' % value),
- None, sys.exc_info[2])
+ raise LookupError('unknown threshold: %r.' % value)
def validate_colon_separated_string_list(
setting, value, option_parser, config_parser=None, config_section=None):
@@ -350,10 +346,9 @@
try:
new_value = self.validator(setting, value, parser)
except Exception as error:
- raise (optparse.OptionValueError(
+ raise optparse.OptionValueError(
'Error in option "%s":\n %s'
- % (opt, ErrorString(error))),
- None, sys.exc_info()[2])
+ % (opt, ErrorString(error)))
setattr(values, setting, new_value)
if self.overrides:
setattr(values, self.overrides, None)
@@ -830,12 +825,12 @@
setting, value, option_parser,
config_parser=self, config_section=section)
except Exception as error:
- raise (ValueError(
+ raise ValueError(
'Error in config file "%s", section "[%s]":\n'
' %s\n'
' %s = %s'
% (filename, section, ErrorString(error),
- setting, value)), None, sys.exc_info()[2])
+ setting, value))
self.set(section, setting, new_value)
if option.overrides:
self.set(section, option.overrides, None)
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -594,8 +594,8 @@
assert key.step in (None, 1), 'cannot handle slice with stride'
return self.children[key.start:key.stop]
else:
- raise TypeError, ('element index must be an integer, a slice, or '
- 'an attribute name string')
+ raise TypeError('element index must be an integer, a slice, or '
+ 'an attribute name string')
def __setitem__(self, key, item):
if isinstance(key, basestring):
@@ -609,8 +609,8 @@
self.setup_child(node)
self.children[key.start:key.stop] = item
else:
- raise TypeError, ('element index must be an integer, a slice, or '
- 'an attribute name string')
+ raise TypeError('element index must be an integer, a slice, or '
+ 'an attribute name string')
def __delitem__(self, key):
if isinstance(key, basestring):
@@ -621,8 +621,8 @@
assert key.step in (None, 1), 'cannot handle slice with stride'
del self.children[key.start:key.stop]
else:
- raise TypeError, ('element index must be an integer, a simple '
- 'slice, or an attribute name string')
+ raise TypeError('element index must be an integer, a simple '
+ 'slice, or an attribute name string')
def __add__(self, other):
return self.children + other
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -57,7 +57,7 @@
"""
# Type check
if not isinstance(node, nodes.Element):
- raise TypeError, 'node must be of Element-derived type.'
+ raise TypeError('node must be of Element-derived type.')
# `node` must not have a title yet.
assert not (len(node) and isinstance(node[0], nodes.title))
@@ -100,7 +100,7 @@
"""
# Type check
if not isinstance(node, nodes.Element):
- raise TypeError, 'node must be of Element-derived type.'
+ raise TypeError('node must be of Element-derived type.')
subsection, index = self.candidate_index(node)
if index is None:
Modified: trunk/docutils/docutils/utils/roman.py
===================================================================
--- trunk/docutils/docutils/utils/roman.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/utils/roman.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -40,9 +40,9 @@
def toRoman(n):
"""convert integer to Roman numeral"""
if not (0 < n < 5000):
- raise OutOfRangeError, "number out of range (must be 1..4999)"
+ raise OutOfRangeError("number out of range (must be 1..4999)")
if int(n) != n:
- raise NotIntegerError, "decimals can not be converted"
+ raise NotIntegerError("decimals can not be converted")
result = ""
for numeral, integer in romanNumeralMap:
@@ -67,9 +67,10 @@
def fromRoman(s):
"""convert Roman numeral to integer"""
if not s:
- raise InvalidRomanNumeralError, 'Input can not be blank'
+ raise InvalidRomanNumeralError('Input can not be blank')
+
if not romanNumeralPattern.search(s):
- raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s
+ raise InvalidRomanNumeralError('Invalid Roman numeral: %s' % s)
result = 0
index = 0
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -715,7 +715,7 @@
pass
def visit_header(self, node):
- raise NotImplementedError, node.astext()
+ raise NotImplementedError(node.astext())
def depart_header(self, node):
pass
@@ -855,7 +855,7 @@
self.depart_literal_block(node)
def visit_meta(self, node):
- raise NotImplementedError, node.astext()
+ raise NotImplementedError(node.astext())
def depart_meta(self, node):
pass
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -123,8 +123,8 @@
operator.
"""
if not first == second:
- raise self.failureException, (
- msg or '%s != %s' % _format_str(first, second))
+ raise self.failureException(
+ msg or '%s != %s' % _format_str(first, second))
def assertNotEqual(self, first, second, msg=None):
"""Fail if the two objects are equal as determined by the '=='
@@ -131,22 +131,9 @@
operator.
"""
if first == second:
- raise self.failureException, (
- msg or '%s == %s' % _format_str(first, second))
+ raise self.failureException(
+ msg or '%s == %s' % _format_str(first, second))
- # assertIn and assertNotIn: new in Python 2.7:
- if sys.version_info < (2,7):
-
- def assertIn(self, a, b, msg=None):
- if a not in b:
- raise self.failureException, (
- msg or '%s not in %s' % _format_str(a, b))
-
- def assertNotIn(self, a, b, msg=None):
- if a in b:
- raise self.failureException, (
- msg or '%s in %s' % _format_str(a, b))
-
# aliases for assertion methods, deprecated since Python 2.7
failUnlessEqual = assertEquals = assertEqual
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -120,7 +120,7 @@
elif isinstance(suite, unittest.TestSuite):
testSuite.addTest(suite)
else:
- raise AssertionError, "don't understand suite (%s)" % mod
+ raise AssertionError("don't understand suite (%s)" % mod)
sys.path.pop(0)
return testSuite
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|