summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-08-15 12:20:11 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-08-15 12:27:02 -0600
commit871d07987b28f4e7657aef7364f776e30b0c7daa (patch)
tree9af3ccc3bc997726f32a01df6eb5331c419e6ca2 /doc
parent3c9c31b19038dbe49c145aa014aa45e0b29b5d4c (diff)
downloadnumpy-871d07987b28f4e7657aef7364f776e30b0c7daa.tar.gz
BUG: Use io.open instead of open for compatibility.
The recent Python 3 fix adding encoding="utf-8" to the open function fails on Python 2 because the encoding keyword is not defined. The solution is to use io.open, which is available for Python 2.6 and 2.7 and is an alias for open when Python >= 3.0. It is reputed to be slow when running in 2.6, but that should not be a problem.
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/postprocess.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/doc/postprocess.py b/doc/postprocess.py
index 257f84806..3955ad6c5 100755
--- a/doc/postprocess.py
+++ b/doc/postprocess.py
@@ -8,7 +8,9 @@ MODE is either 'html' or 'tex'.
"""
from __future__ import division, absolute_import, print_function
-import re, optparse
+import re
+import optparse
+import io
def main():
p = optparse.OptionParser(__doc__)
@@ -23,7 +25,7 @@ def main():
p.error('unknown mode %s' % mode)
for fn in args:
- f = open(fn, 'r', encoding="utf-8")
+ f = io.open(fn, 'r', encoding="utf-8")
try:
if mode == 'html':
lines = process_html(fn, f.readlines())
@@ -32,7 +34,7 @@ def main():
finally:
f.close()
- f = open(fn, 'w', encoding="utf-8")
+ f = io.open(fn, 'w', encoding="utf-8")
f.write("".join(lines))
f.close()