mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +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
|
@ -1540,7 +1540,7 @@ class TarFile(object):
|
|||
self.chown(tarinfo, path)
|
||||
self.utime(tarinfo, path)
|
||||
self.chmod(tarinfo, path)
|
||||
except ExtractError, e:
|
||||
except ExtractError as e:
|
||||
if self.errorlevel > 1:
|
||||
raise
|
||||
else:
|
||||
|
@ -1565,7 +1565,7 @@ class TarFile(object):
|
|||
|
||||
try:
|
||||
self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
if self.errorlevel > 0:
|
||||
raise
|
||||
else:
|
||||
|
@ -1573,7 +1573,7 @@ class TarFile(object):
|
|||
self._dbg(1, "tarfile: %s" % e.strerror)
|
||||
else:
|
||||
self._dbg(1, "tarfile: %s %r" % (e.strerror, e.filename))
|
||||
except ExtractError, e:
|
||||
except ExtractError as e:
|
||||
if self.errorlevel > 1:
|
||||
raise
|
||||
else:
|
||||
|
@ -1681,7 +1681,7 @@ class TarFile(object):
|
|||
"""
|
||||
try:
|
||||
os.mkdir(targetpath)
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
|
@ -1745,11 +1745,11 @@ class TarFile(object):
|
|||
|
||||
try:
|
||||
self._extract_member(self.getmember(linkpath), targetpath)
|
||||
except (EnvironmentError, KeyError), e:
|
||||
except (EnvironmentError, KeyError) as e:
|
||||
linkpath = os.path.normpath(linkpath)
|
||||
try:
|
||||
shutil.copy2(linkpath, targetpath)
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
raise IOError("link could not be created")
|
||||
|
||||
def chown(self, tarinfo, targetpath):
|
||||
|
@ -1777,7 +1777,7 @@ class TarFile(object):
|
|||
else:
|
||||
if sys.platform != "os2emx":
|
||||
os.chown(targetpath, u, g)
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
raise ExtractError("could not change owner")
|
||||
|
||||
def chmod(self, tarinfo, targetpath):
|
||||
|
@ -1786,7 +1786,7 @@ class TarFile(object):
|
|||
if hasattr(os, 'chmod'):
|
||||
try:
|
||||
os.chmod(targetpath, tarinfo.mode)
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
raise ExtractError("could not change mode")
|
||||
|
||||
def utime(self, tarinfo, targetpath):
|
||||
|
@ -1800,7 +1800,7 @@ class TarFile(object):
|
|||
return
|
||||
try:
|
||||
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
raise ExtractError("could not change modification time")
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
|
@ -1833,7 +1833,7 @@ class TarFile(object):
|
|||
|
||||
tarinfo = self.proc_member(tarinfo)
|
||||
|
||||
except HeaderError, e:
|
||||
except HeaderError as e:
|
||||
if self.ignore_zeros:
|
||||
self._dbg(2, "0x%X: %s" % (self.offset, e))
|
||||
self.offset += BLOCKSIZE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue