summaryrefslogtreecommitdiff
path: root/engine/SCons/Errors.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-01 13:23:10 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-01 13:23:10 +0200
commit0414abd565dbdf12ea741930bef5268bc7fe6da3 (patch)
treeaa7e983f81ffe2090fa31869b6670bf18bcc28a0 /engine/SCons/Errors.py
parent3765e33b76c51c81dd7bbbfacab0c4e76a1713cb (diff)
parent3bab2962eecc24c19366692e52ebca5eb835d117 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'engine/SCons/Errors.py')
-rw-r--r--engine/SCons/Errors.py128
1 files changed, 76 insertions, 52 deletions
diff --git a/engine/SCons/Errors.py b/engine/SCons/Errors.py
index 801cf55..8388a0f 100644
--- a/engine/SCons/Errors.py
+++ b/engine/SCons/Errors.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -28,72 +28,74 @@ and user errors in SCons.
"""
-__revision__ = "src/engine/SCons/Errors.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Errors.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+import shutil
import SCons.Util
-import exceptions
class BuildError(Exception):
- """ Errors occuring while building.
+ """ Errors occurring while building.
BuildError have the following attributes:
+ =========================================
- Information about the cause of the build error:
- -----------------------------------------------
+ Information about the cause of the build error:
+ -----------------------------------------------
- errstr : a description of the error message
+ errstr : a description of the error message
- status : the return code of the action that caused the build
- error. Must be set to a non-zero value even if the
- build error is not due to an action returning a
- non-zero returned code.
+ status : the return code of the action that caused the build error.
+ Must be set to a non-zero value even if the build error is not due
+ to an action returning a non-zero returned code.
- exitstatus : SCons exit status due to this build error.
- Must be nonzero unless due to an explicit Exit()
- call. Not always the same as status, since
- actions return a status code that should be
- respected, but SCons typically exits with 2
- irrespective of the return value of the failed
- action.
+ exitstatus : SCons exit status due to this build error.
+ Must be nonzero unless due to an explicit Exit()
+ call. Not always the same as status, since
+ actions return a status code that should be
+ respected, but SCons typically exits with 2
+ irrespective of the return value of the failed
+ action.
- filename : The name of the file or directory that caused the
- build error. Set to None if no files are associated with
- this error. This might be different from the target
- being built. For example, failure to create the
- directory in which the target file will appear. It
- can be None if the error is not due to a particular
- filename.
+ filename : The name of the file or directory that caused the
+ build error. Set to None if no files are associated with
+ this error. This might be different from the target
+ being built. For example, failure to create the
+ directory in which the target file will appear. It
+ can be None if the error is not due to a particular
+ filename.
- exc_info : Info about exception that caused the build
- error. Set to (None, None, None) if this build
- error is not due to an exception.
+ exc_info : Info about exception that caused the build
+ error. Set to (None, None, None) if this build
+ error is not due to an exception.
- Information about the cause of the location of the error:
- ---------------------------------------------------------
+ Information about the cause of the location of the error:
+ ---------------------------------------------------------
- node : the error occured while building this target node(s)
-
- executor : the executor that caused the build to fail (might
- be None if the build failures is not due to the
- executor failing)
-
- action : the action that caused the build to fail (might be
- None if the build failures is not due to the an
- action failure)
+ node : the error occured while building this target node(s)
+
+ executor : the executor that caused the build to fail (might
+ be None if the build failures is not due to the
+ executor failing)
- command : the command line for the action that caused the
- build to fail (might be None if the build failures
- is not due to the an action failure)
- """
+ action : the action that caused the build to fail (might be
+ None if the build failures is not due to the an
+ action failure)
+
+ command : the command line for the action that caused the
+ build to fail (might be None if the build failures
+ is not due to the an action failure)
+ """
- def __init__(self,
+ def __init__(self,
node=None, errstr="Unknown error", status=2, exitstatus=2,
filename=None, executor=None, action=None, command=None,
exc_info=(None, None, None)):
-
- self.errstr = errstr
+
+ # py3: errstr should be string and not bytes.
+
+ self.errstr = SCons.Util.to_str(errstr)
self.status = status
self.exitstatus = exitstatus
self.filename = filename
@@ -104,7 +106,7 @@ class BuildError(Exception):
self.action = action
self.command = command
- Exception.__init__(self, node, errstr, status, exitstatus, filename,
+ Exception.__init__(self, node, errstr, status, exitstatus, filename,
executor, action, command, exc_info)
def __str__(self):
@@ -139,13 +141,17 @@ def convert_to_BuildError(status, exc_info=None):
"""
Convert any return code a BuildError Exception.
- `status' can either be a return code or an Exception.
+ :Parameters:
+ - `status`: can either be a return code or an Exception.
+
The buildError.status we set here will normally be
used as the exit status of the "scons" process.
"""
+
if not exc_info and isinstance(status, Exception):
exc_info = (status.__class__, status, None)
+
if isinstance(status, BuildError):
buildError = status
buildError.exitstatus = 2 # always exit with 2 on build errors
@@ -163,14 +169,32 @@ def convert_to_BuildError(status, exc_info=None):
status=2,
exitstatus=2,
exc_info=exc_info)
- elif isinstance(status, exceptions.EnvironmentError):
+ elif isinstance(status, shutil.SameFileError):
+ # PY3 has a exception for when copying file to itself
+ # It's object provides info differently than below
+ try:
+ filename = status.filename
+ except AttributeError:
+ filename = None
+
+ buildError = BuildError(
+ errstr=status.args[0],
+ status=status.errno,
+ exitstatus=2,
+ filename=filename,
+ exc_info=exc_info)
+
+ elif isinstance(status, (EnvironmentError, OSError, IOError)):
# If an IOError/OSError happens, raise a BuildError.
# Report the name of the file or directory that caused the
# error, which might be different from the target being built
# (for example, failure to create the directory in which the
# target file will appear).
- try: filename = status.filename
- except AttributeError: filename = None
+ try:
+ filename = status.filename
+ except AttributeError:
+ filename = None
+
buildError = BuildError(
errstr=status.strerror,
status=status.errno,
@@ -195,7 +219,7 @@ def convert_to_BuildError(status, exc_info=None):
exitstatus=2)
#import sys
- #sys.stderr.write("convert_to_BuildError: status %s => (errstr %s, status %s)"%(status,buildError.errstr, buildError.status))
+ #sys.stderr.write("convert_to_BuildError: status %s => (errstr %s, status %s)\n"%(status,buildError.errstr, buildError.status))
return buildError
# Local Variables: