diff options
author | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-24 07:15:29 +0000 |
---|---|---|
committer | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-24 07:15:29 +0000 |
commit | 72f22c7a12752a8aa423a748b680db4e755343c6 (patch) | |
tree | ab530a95f7e1d012c82ffd6b8a0e39b51adec7c2 | |
parent | 356dd12af3a9f4d63efe894ec7023ed196144531 (diff) | |
download | docutils-72f22c7a12752a8aa423a748b680db4e755343c6.tar.gz |
changes to remove py2.6 -3 deprecation warnings
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/abolish-userstring-haskey@5612 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r-- | docutils/parsers/rst/states.py | 3 | ||||
-rw-r--r-- | docutils/statemachine.py | 2 | ||||
-rw-r--r-- | extras/optparse.py | 2 | ||||
-rw-r--r-- | extras/roman.py | 2 | ||||
-rw-r--r-- | test/docutils_difflib.py | 13 | ||||
-rw-r--r-- | test/functional/tests/standalone_rst_html4css1.py | 2 | ||||
-rw-r--r-- | test/functional/tests/standalone_rst_latex.py | 2 | ||||
-rw-r--r-- | test/functional/tests/standalone_rst_pseudoxml.py | 2 | ||||
-rwxr-xr-x | test/functional/tests/standalone_rst_s5_html_1.py | 2 | ||||
-rwxr-xr-x | test/functional/tests/standalone_rst_s5_html_2.py | 2 | ||||
-rwxr-xr-x | test/test_functional.py | 5 | ||||
-rwxr-xr-x | tools/dev/profile_docutils.py | 2 |
12 files changed, 21 insertions, 18 deletions
diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b20c9f4d9..d5efb20e5 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2249,7 +2249,8 @@ class Body(RSTState): if expmatch: try: return method(self, expmatch) - except MarkupError, (message, lineno): # never reached? + except MarkupError, error: # never reached? + message, lineno = error.args errors.append(self.reporter.warning(message, line=lineno)) break nodelist, blank_finish = self.comment(match) diff --git a/docutils/statemachine.py b/docutils/statemachine.py index f38ea66b7..c29f128a7 100644 --- a/docutils/statemachine.py +++ b/docutils/statemachine.py @@ -377,7 +377,7 @@ class StateMachine: self.next_line(len(block) - 1) return block except UnexpectedIndentationError, error: - block, source, lineno = error + block, source, lineno = error.args self.next_line(len(block) - 1) # advance to last line of block raise diff --git a/extras/optparse.py b/extras/optparse.py index ae769301d..dcc36fd84 100644 --- a/extras/optparse.py +++ b/extras/optparse.py @@ -704,7 +704,7 @@ class Values: def read_file (self, filename, mode="careful"): vars = {} - execfile(filename, vars) + exec(open(filename).read(), vars) self._update(vars, mode) def ensure_value (self, attr, value): diff --git a/extras/roman.py b/extras/roman.py index ebe088308..0335f29f8 100644 --- a/extras/roman.py +++ b/extras/roman.py @@ -41,7 +41,7 @@ def toRoman(n): """convert integer to Roman numeral""" if not (0 < n < 5000): raise OutOfRangeError, "number out of range (must be 1..4999)" - if int(n) <> n: + if int(n) != n: raise NotIntegerError, "decimals can not be converted" result = "" diff --git a/test/docutils_difflib.py b/test/docutils_difflib.py index 1865c2117..cc84c485a 100644 --- a/test/docutils_difflib.py +++ b/test/docutils_difflib.py @@ -525,8 +525,9 @@ class SequenceMatcher: 1.0 """ - matches = reduce(lambda sum, triple: sum + triple[-1], - self.get_matching_blocks(), 0) + matches = 0 + for triple in self.get_matching_blocks(): + matches += triple[-1] return 2.0 * matches / (len(self.a) + len(self.b)) def quick_ratio(self): @@ -600,9 +601,9 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6): """ if not n > 0: - raise ValueError("n must be > 0: " + `n`) + raise ValueError("n must be > 0: " + repr(n)) if not 0.0 <= cutoff <= 1.0: - raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`) + raise ValueError("cutoff must be in [0.0, 1.0]: " + repr(cutoff)) result = [] s = SequenceMatcher() s.set_seq2(word) @@ -788,7 +789,7 @@ class Differ: elif tag == 'equal': self._dump(' ', a, alo, ahi) else: - raise ValueError, 'unknown tag ' + `tag` + raise ValueError, 'unknown tag ' + repr(tag) results = self.results self.results = [] return results @@ -904,7 +905,7 @@ class Differ: atags += ' ' * la btags += ' ' * lb else: - raise ValueError, 'unknown tag ' + `tag` + raise ValueError, 'unknown tag ' + repr(tag) self._qformat(aelt, belt, atags, btags) else: # the synch pair is identical diff --git a/test/functional/tests/standalone_rst_html4css1.py b/test/functional/tests/standalone_rst_html4css1.py index c34298eab..9f80e6d79 100644 --- a/test/functional/tests/standalone_rst_html4css1.py +++ b/test/functional/tests/standalone_rst_html4css1.py @@ -1,4 +1,4 @@ -execfile('functional/tests/_standalone_rst_defaults.py') +exec(open('functional/tests/_standalone_rst_defaults.py').read()) # Source and destination file names. test_source = "standalone_rst_html4css1.txt" diff --git a/test/functional/tests/standalone_rst_latex.py b/test/functional/tests/standalone_rst_latex.py index f0c40b75a..39a5e1e5e 100644 --- a/test/functional/tests/standalone_rst_latex.py +++ b/test/functional/tests/standalone_rst_latex.py @@ -1,4 +1,4 @@ -execfile('functional/tests/_standalone_rst_defaults.py') +exec(open('functional/tests/_standalone_rst_defaults.py').read()) # Source and destination file names. test_source = "standalone_rst_latex.txt" diff --git a/test/functional/tests/standalone_rst_pseudoxml.py b/test/functional/tests/standalone_rst_pseudoxml.py index b9b2df309..7f9b06f04 100644 --- a/test/functional/tests/standalone_rst_pseudoxml.py +++ b/test/functional/tests/standalone_rst_pseudoxml.py @@ -1,4 +1,4 @@ -execfile('functional/tests/_standalone_rst_defaults.py') +exec(open('functional/tests/_standalone_rst_defaults.py').read()) # Source and destination file names. test_source = "standalone_rst_pseudoxml.txt" diff --git a/test/functional/tests/standalone_rst_s5_html_1.py b/test/functional/tests/standalone_rst_s5_html_1.py index ce27f687a..9939ad688 100755 --- a/test/functional/tests/standalone_rst_s5_html_1.py +++ b/test/functional/tests/standalone_rst_s5_html_1.py @@ -1,4 +1,4 @@ -execfile('functional/tests/_standalone_rst_defaults.py') +exec(open('functional/tests/_standalone_rst_defaults.py').read()) # Source and destination file names: test_source = 'standalone_rst_s5_html.txt' diff --git a/test/functional/tests/standalone_rst_s5_html_2.py b/test/functional/tests/standalone_rst_s5_html_2.py index aea7a9207..385558ac3 100755 --- a/test/functional/tests/standalone_rst_s5_html_2.py +++ b/test/functional/tests/standalone_rst_s5_html_2.py @@ -1,5 +1,5 @@ # initialize with the settings & definitions from test 1: -execfile('functional/tests/standalone_rst_s5_html_1.py') +exec(open('functional/tests/standalone_rst_s5_html_1.py').read()) # overrides specific to this test: test_destination = 'standalone_rst_s5_html_2.html' diff --git a/test/test_functional.py b/test/test_functional.py index 9d129f412..d2dff949d 100755 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -92,8 +92,9 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase): namespace['settings_overrides'] = {'_disable_config': 1} # Read the variables set in the default config file and in # the current config file into namespace: - execfile(join_path(datadir, 'tests', '_default.py'), namespace) - execfile(self.configfile, namespace) + defaultpy = open(join_path(datadir, 'tests', '_default.py')).read() + exec(defaultpy, namespace) + exec(open(self.configfile).read(), namespace) # Check for required settings: assert 'test_source' in namespace,\ "No 'test_source' supplied in " + self.configfile diff --git a/tools/dev/profile_docutils.py b/tools/dev/profile_docutils.py index e342b0239..90b083787 100755 --- a/tools/dev/profile_docutils.py +++ b/tools/dev/profile_docutils.py @@ -34,6 +34,6 @@ stats.sort_stats('time') stats.print_stats(40) try: - execfile(os.environ['PYTHONSTARTUP']) + exec(open(os.environ['PYTHONSTARTUP']).read()) except: pass |