8000 Issue #16706: get rid of os.error · python/cpython@ad28c7f · GitHub
[go: up one dir, main page]

Skip to content

Commit ad28c7f

Browse files
committed
Issue #16706: get rid of os.error
1 parent a191959 commit ad28c7f

33 files changed

+4069
-4103
lines changed

Lib/_pyio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
200200
buffering = DEFAULT_BUFFER_SIZE
201201
try:
202202
bs = os.fstat(raw.fileno()).st_blksize
203-
except (os.error, AttributeError):
203+
except (OSError, AttributeError):
204204
pass
205205
else:
206206
if bs > 1:

Lib/cgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ def print_directory():
949949
print("<H3>Current Working Directory:</H3>")
950950
try:
951951
pwd = os.getcwd()
952-
except os.error as msg:
952+
except OSError as msg:
953953
print("os.error:", html.escape(str(msg)))
954954
else:
955955
print(html.escape(pwd))

Lib/compileall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
3838
print('Listing {!r}...'.format(dir))
3939
try:
4040
names = os.listdir(dir)
41-
except os.error:
41+
except OSError:
4242
print("Can't list {!r}".format(dir))
4343
names = []
4444
names.sort()

Lib/dbm/dumb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ def _commit(self):
100100

101101
try:
102102
self._os.unlink(self._bakfile)
103-
except self._os.error:
103+
except OSError:
104104
pass
105105

106106
try:
107107
self._os.rename(self._dirfile, self._bakfile)
108-
except self._os.error:
108+
except OSError:
109109
pass
110110

111111
f = self._io.open(self._dirfile, 'w', encoding="Latin-1")

Lib/distutils/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class found in 'cmdclass' is used in place of the default, which is
148148
dist.run_commands()
149149
except KeyboardInterrupt:
150150
raise SystemExit("interrupted")
151-
except (IOError, os.error) as exc:
151+
except (IOError, OSError) as exc:
152152
error = grok_environment_error(exc)
153153

154154
if DEBUG:

Lib/distutils/dir_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
124124
"cannot copy tree '%s': not a directory" % src)
125125
try:
126126
names = os.listdir(src)
127-
except os.error as e:
127+
except OSError as e:
128128
(errno, errstr) = e
129129
if dry_run:
130130
names = []

Lib/distutils/file_util.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ def _copy_file_contents(src, dst, buffer_size=16*1024):
2727
try:
2828
try:
2929
fsrc = open(src, 'rb')
30-
except os.error as e:
30+
except OSError as e:
3131
raise DistutilsFileError("could not open '%s': %s" % (src, e.strerror))
3232

3333
if os.path.exists(dst):
3434
try:
3535
os.unlink(dst)
36-
except os.error as e:
36+
except OSError as e:
3737
raise DistutilsFileError(
3838
"could not delete '%s': %s" % (dst, e.strerror))
3939

4040
try:
4141
fdst = open(dst, 'wb')
42-
except os.error as e:
42+
except OSError as e:
4343
raise DistutilsFileError(
4444
"could not create '%s': %s" % (dst, e.strerror))
4545

4646
while True:
4747
try:
4848
buf = fsrc.read(buffer_size)
49-
except os.error as e:
49+
except OSError as e:
5050
raise DistutilsFileError(
5151
"could not read from '%s': %s" % (src, e.strerror))
5252

@@ -55,7 +55,7 @@ def _copy_file_contents(src, dst, buffer_size=16*1024):
5555

5656
try:
5757
fdst.write(buf)
58-
except os.error as e:
58+
except OSError as e:
5959
raise DistutilsFileError(
6060
"could not write to '%s': %s" % (dst, e.strerror))
6161
finally:
@@ -193,7 +193,7 @@ def move_file (src, dst,
193193
copy_it = False
194194
try:
195195
os.rename(src, dst)
196-
except os.error as e:
196+
except OSError as e:
197197
(num, msg) = e
198198
if num == errno.EXDEV:
199199
copy_it = True
@@ -205,11 +205,11 @@ def move_file (src, dst,
205205
copy_file(src, dst, verbose=verbose)
206206
try:
207207
os.unlink(src)
208-
except os.error as e:
208+
except OSError as e:
209209
(num, msg) = e
210210
try:
211211
os.unlink(dst)
212-
except os.error:
212+
except OSError:
213213
pass
214214
raise DistutilsFileError(
215215
"couldn't move '%s' to '%s' by copy/delete: "

Lib/fileinput.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,10 @@ def readline(self):
324324
if self._inplace:
325325
self._backupfilename = (
326326
self._filename + (self._backup or ".bak"))
327-
try: os.unlink(self._backupfilename)
328-
except os.error: pass
327+
try:
328+
os.unlink(self._backupfilename)
329+
except OSError:
330+
pass
329331
# The next few lines may raise IOError
330332
os.rename(self._filename, self._backupfilename)
331333
self._file = open(self._backupfilename, self._mode)

Lib/genericpath.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def exists(path):
1616
"""Test whether a path exists. Returns False for broken symbolic links"""
1717
try:
1818
os.stat(path)
19-
except os.error:
19+
except OSError:
2020
return False
2121
return True
2222

@@ -27,7 +27,7 @@ def isfile(path):
2727
"""Test whether a path is a regular file"""
2828
try:
2929
st = os.stat(path)
30-
except os.error:
30+
except OSError:
3131
return False
3232
return stat.S_ISREG(st.st_mode)
3333

@@ -39,7 +39,7 @@ def isdir(s):
3939
"""Return true if the pathname refers to an existing directory."""
4040
try:
4141
st = os.stat(s)
42-
except os.error:
42+
except OSError:
4343
return False
4444
return stat.S_ISDIR(st.st_mode)
4545

Lib/glob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def glob1(dirname, pattern):
5555
dirname = os.curdir
5656
try:
5757
names = os.listdir(dirname)
58-
except os.error:
58+
except OSError:
5959
return []
6060
if pattern[0] != '.':
6161
names = [x for x in names if x[0] != '.']

0 commit comments

Comments
 (0)
0