diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2013-03-05 12:09:12 -0700 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2013-03-05 13:31:39 -0700 |
| commit | 342f074eb412e4cc19ab31a35a4ca04449e61597 (patch) | |
| tree | 78c3e4656d6718c427ea9e9b578ad7f64330a82a /numpy/distutils/command | |
| parent | 9311fb7e861e2c8eb686abded01c059b49f0b5e4 (diff) | |
| download | numpy-342f074eb412e4cc19ab31a35a4ca04449e61597.tar.gz | |
2to3: Remove xreadlines and replace f.readlines() by f where valid.
An open file `f` has been an iterator since python2.3 and
`f.xreadlines()` is no longer needed, so replace it with `f`. Also
replace `f.readlines()` with `f` where an iterator will do. The
replacement of `f.readlines()` is not critical because it is a list in
both python2 and python3, but the code is a bit cleaner.
Closes #3093
Diffstat (limited to 'numpy/distutils/command')
| -rw-r--r-- | numpy/distutils/command/build_src.py | 8 | ||||
| -rw-r--r-- | numpy/distutils/command/install.py | 2 |
2 files changed, 4 insertions, 6 deletions
diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index a9e66e6f4..cacfc472b 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -37,7 +37,7 @@ def subst_vars(target, source, d): try: ft = open(target, 'w') try: - for l in fs.readlines(): + for l in fs: m = var.search(l) if m: ft.write(l.replace('@%s@' % m.group(1), d[m.group(1)])) @@ -767,9 +767,8 @@ def get_swig_target(source): def get_swig_modulename(source): f = open(source,'r') - f_readlines = getattr(f,'xreadlines',f.readlines) name = None - for line in f_readlines(): + for line in f: m = _swig_module_name_match(line) if m: name = m.group('name') @@ -794,8 +793,7 @@ _f2py_user_module_name_match = re.compile(r'\s*python\s*module\s*(?P<name>[\w_]* def get_f2py_modulename(source): name = None f = open(source) - f_readlines = getattr(f,'xreadlines',f.readlines) - for line in f_readlines(): + for line in f: m = _f2py_module_name_match(line) if m: if _f2py_user_module_name_match(line): # skip *__user__* names diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py index ea898ade9..d9b84fc08 100644 --- a/numpy/distutils/command/install.py +++ b/numpy/distutils/command/install.py @@ -64,7 +64,7 @@ class install(old_install): f = open(self.record,'r') lines = [] need_rewrite = False - for l in f.readlines(): + for l in f: l = l.rstrip() if ' ' in l: need_rewrite = True |
