summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/distutils/conv_template.py11
-rw-r--r--numpy/distutils/from_template.py12
2 files changed, 8 insertions, 15 deletions
diff --git a/numpy/distutils/conv_template.py b/numpy/distutils/conv_template.py
index e8823ed53..3bcb7b884 100644
--- a/numpy/distutils/conv_template.py
+++ b/numpy/distutils/conv_template.py
@@ -87,7 +87,6 @@ import os
import sys
import re
-from numpy.compat import contextlib_nullcontext
from numpy.distutils.compat import get_exception
# names for replacement that are already global.
@@ -317,24 +316,22 @@ def main():
try:
file = sys.argv[1]
except IndexError:
- fid = contextlib_nullcontext(sys.stdin)
- outfile = contextlib_nullcontext(sys.stdout)
+ fid = sys.stdin
+ outfile = sys.stdout
else:
fid = open(file, 'r')
(base, ext) = os.path.splitext(file)
newname = base
outfile = open(newname, 'w')
- with fid:
- allstr = fid.read()
+ allstr = fid.read()
try:
writestr = process_str(allstr)
except ValueError:
e = get_exception()
raise ValueError("In %s loop at %s" % (file, e))
- with outfile:
- outfile.write(writestr)
+ outfile.write(writestr)
if __name__ == "__main__":
main()
diff --git a/numpy/distutils/from_template.py b/numpy/distutils/from_template.py
index 026de0093..c5c1163c6 100644
--- a/numpy/distutils/from_template.py
+++ b/numpy/distutils/from_template.py
@@ -53,8 +53,6 @@ import os
import sys
import re
-from numpy.compat import contextlib_nullcontext
-
routine_start_re = re.compile(r'(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\b', re.I)
routine_end_re = re.compile(r'\n\s*end\s*(subroutine|function)\b.*(\n|\Z)', re.I)
function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I)
@@ -249,19 +247,17 @@ def main():
try:
file = sys.argv[1]
except IndexError:
- fid = contextlib_nullcontext(sys.stdin)
- outfile = contextlib_nullcontext(sys.stdout)
+ fid = sys.stdin
+ outfile = sys.stdout
else:
fid = open(file, 'r')
(base, ext) = os.path.splitext(file)
newname = base
outfile = open(newname, 'w')
- with fid:
- allstr = fid.read()
+ allstr = fid.read()
writestr = process_str(allstr)
- with outfile:
- outfile.write(writestr)
+ outfile.write(writestr)
if __name__ == "__main__":