mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V" (b) V is now limited to a simple name (local variable) (c) V is now deleted at the end of the except block
This commit is contained in:
parent
893523e80a
commit
b940e113bf
295 changed files with 817 additions and 743 deletions
|
@ -121,18 +121,18 @@ def copytree(src, dst, symlinks=False):
|
|||
else:
|
||||
copy2(srcname, dstname)
|
||||
# XXX What about devices, sockets etc.?
|
||||
except (IOError, os.error), why:
|
||||
except (IOError, os.error) as why:
|
||||
errors.append((srcname, dstname, str(why)))
|
||||
# catch the Error from the recursive copytree so that we can
|
||||
# continue with other files
|
||||
except Error, err:
|
||||
except Error as err:
|
||||
errors.extend(err.args[0])
|
||||
try:
|
||||
copystat(src, dst)
|
||||
except WindowsError:
|
||||
# can't copy file access times on Windows
|
||||
pass
|
||||
except OSError, why:
|
||||
except OSError as why:
|
||||
errors.extend((src, dst, str(why)))
|
||||
if errors:
|
||||
raise Error, errors
|
||||
|
@ -157,7 +157,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
|
|||
names = []
|
||||
try:
|
||||
names = os.listdir(path)
|
||||
except os.error, err:
|
||||
except os.error as err:
|
||||
onerror(os.listdir, path, sys.exc_info())
|
||||
for name in names:
|
||||
fullname = os.path.join(path, name)
|
||||
|
@ -170,7 +170,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
|
|||
else:
|
||||
try:
|
||||
os.remove(fullname)
|
||||
except os.error, err:
|
||||
except os.error as err:
|
||||
onerror(os.remove, fullname, sys.exc_info())
|
||||
try:
|
||||
os.rmdir(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue