From 4340bf34faca7eed8076ba4c388fbe15355f2183 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 4 Mar 2021 17:02:31 -0500 Subject: various python neatness cleanups All changes were created by running "pyupgrade --py3-only --keep-percent-format" and committing the results. I have not touched string formatting for now. - use set literals - simplify .format() parameter naming - remove __future__ - remove default "r" mode for open() - use OSError rather than compatibility aliases - remove stray parentheses in function(generator) scopes --- mesonbuild/scripts/meson_exe.py | 2 +- mesonbuild/scripts/symbolextractor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/scripts') diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py index 27db14423..d44280fc3 100644 --- a/mesonbuild/scripts/meson_exe.py +++ b/mesonbuild/scripts/meson_exe.py @@ -82,7 +82,7 @@ def run_exe(exe: ExecutableSerialisation, extra_env: T.Optional[dict] = None) -> try: with open(exe.capture, 'rb') as cur: skip_write = cur.read() == stdout - except IOError: + except OSError: pass if not skip_write: with open(exe.capture, 'wb') as output: diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index 30065cc4b..e80d9c2fac 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -43,7 +43,7 @@ def dummy_syms(outfilename: str) -> None: def write_if_changed(text: str, outfilename: str) -> None: try: - with open(outfilename, 'r') as f: + with open(outfilename) as f: oldtext = f.read() if text == oldtext: return -- cgit v1.2.3