mirror of https://github.com/python/cpython.git
Merged in code from the 0.1.5 release to handle IOError and OSError
exceptions better.
This commit is contained in:
parent
6a9a545ab1
commit
d80506c238
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys
|
import sys, os
|
||||||
from types import *
|
from types import *
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.dist import Distribution
|
from distutils.dist import Distribution
|
||||||
|
@ -89,13 +89,19 @@ def setup (**attrs):
|
||||||
dist.run_commands ()
|
dist.run_commands ()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise SystemExit, "interrupted"
|
raise SystemExit, "interrupted"
|
||||||
except (OSError, IOError), exc:
|
except (IOError, os.error), exc:
|
||||||
# arg, try to work with Python pre-1.5.2
|
# check for Python 1.5.2-style {IO,OS}Error exception objects
|
||||||
if hasattr (exc, 'filename') and hasattr (exc, 'strerror'):
|
if hasattr (exc, 'filename') and hasattr (exc, 'strerror'):
|
||||||
raise SystemExit, \
|
if exc.filename:
|
||||||
"error: %s: %s" % (exc.filename, exc.strerror)
|
raise SystemExit, \
|
||||||
|
"error: %s: %s" % (exc.filename, exc.strerror)
|
||||||
|
else:
|
||||||
|
# two-argument functions in posix module don't
|
||||||
|
# include the filename in the exception object!
|
||||||
|
raise SystemExit, \
|
||||||
|
"error: %s" % exc.strerror
|
||||||
else:
|
else:
|
||||||
raise SystemExit, str (exc)
|
raise SystemExit, "error: " + exc[-1]
|
||||||
except (DistutilsExecError,
|
except (DistutilsExecError,
|
||||||
DistutilsFileError,
|
DistutilsFileError,
|
||||||
DistutilsOptionError), msg:
|
DistutilsOptionError), msg:
|
||||||
|
|
Loading…
Reference in New Issue