Skip to content

Commit 2bc5890

Browse files
Apply ruff/pyupgrade rule UP024
UP024 Replace aliased errors with `OSError`
1 parent 342b8c9 commit 2bc5890

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

demo/btrfs-snap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
args_buffer = ffi.buffer(args)
4646
try:
4747
fcntl.ioctl(target, lib.BTRFS_IOC_SNAP_CREATE_V2, args_buffer)
48-
except IOError as e:
48+
except OSError as e:
4949
print(e)
5050
sys.exit(1)
5151

src/cffi/pkgconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def call(libname, flag, encoding=sys.getfilesystemencoding()):
3131
a.append(libname)
3232
try:
3333
pc = subprocess.Popen(a, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
34-
except EnvironmentError as e:
34+
except OSError as e:
3535
raise PkgConfigError("cannot run pkg-config: %s" % (str(e).strip(),))
3636

3737
bout, berr = pc.communicate()

src/cffi/recompiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,11 +1435,11 @@ def _make_c_or_py_source(ffi, module_name, preamble, target_file, verbose):
14351435
try:
14361436
with open(target_file, 'r') as f1:
14371437
if f1.read(len(output) + 1) != output:
1438-
raise IOError
1438+
raise OSError
14391439
if verbose:
14401440
print("(already up-to-date)")
14411441
return False # already up-to-date
1442-
except IOError:
1442+
except OSError:
14431443
tmp_file = '%s.~%d' % (target_file, os.getpid())
14441444
with open(tmp_file, 'w') as f1:
14451445
f1.write(output)

testing/cffi1/test_commontypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def getlines():
77
try:
88
f = open(os.path.join(os.path.dirname(cffi.__file__),
99
'..', 'c', 'commontypes.c'))
10-
except IOError:
10+
except OSError:
1111
pytest.skip("cannot find ../c/commontypes.c")
1212
lines = [line for line in f.readlines() if line.strip().startswith('EQ(')]
1313
f.close()

0 commit comments

Comments
 (0)