Skip to content

Commit 91fe400

Browse files
committed
In compiler package, rely on compiler errors.
1 parent 3fe42b9 commit 91fe400

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

distutils/compilers/C/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
from ..._modified import newer_group
1717
from ...dir_util import mkpath
1818
from ...errors import (
19-
CompileError,
2019
DistutilsModuleError,
2120
DistutilsPlatformError,
22-
LinkError,
23-
UnknownFileError,
2421
)
2522
from ...file_util import move_file
2623
from ...spawn import spawn
2724
from ...util import execute, is_mingw, split_quoted
25+
from .errors import (
26+
CompileError,
27+
LinkError,
28+
UnknownFileType,
29+
)
2830

2931

3032
class Compiler:
@@ -989,7 +991,7 @@ def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
989991
try:
990992
new_ext = extensions[src.suffix]
991993
except LookupError:
992-
raise UnknownFileError(f"unknown file type '{src.suffix}' (from '{src}')")
994+
raise UnknownFileType(f"unknown file type '{src.suffix}' (from '{src}')")
993995
if strip_dir:
994996
base = pathlib.PurePath(base.name)
995997
return os.path.join(output_dir, base.with_suffix(new_ext))

distutils/compilers/C/cygwin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
from subprocess import check_output
1616

1717
from ...errors import (
18-
CCompilerError,
19-
CompileError,
2018
DistutilsExecError,
2119
DistutilsPlatformError,
2220
)
2321
from ...file_util import write_file
2422
from ...sysconfig import get_config_vars
2523
from ...version import LooseVersion, suppress_known_deprecation
2624
from . import unix
25+
from .errors import (
26+
CompileError,
27+
Error,
28+
)
2729

2830

2931
def get_msvcr():
@@ -250,7 +252,7 @@ def __init__(self, verbose=False, dry_run=False, force=False):
250252
shared_option = "-shared"
251253

252254
if is_cygwincc(self.cc):
253-
raise CCompilerError('Cygwin gcc cannot be used with --compiler=mingw32')
255+
raise Error('Cygwin gcc cannot be used with --compiler=mingw32')
254256

255257
self.set_executables(
256258
compiler=f'{self.cc} -O -Wall',

distutils/compilers/C/msvc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@
2525

2626
from ..._log import log
2727
from ...errors import (
28-
CompileError,
2928
DistutilsExecError,
3029
DistutilsPlatformError,
31-
LibError,
32-
LinkError,
3330
)
3431
from ...util import get_host_platform, get_platform
3532
from . import base
3633
from .base import gen_lib_options
34+
from .errors import (
35+
CompileError,
36+
LibError,
37+
LinkError,
38+
)
3739

3840

3941
def _find_vc2015():

distutils/compilers/C/unix.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@
2626
from ..._macos_compat import compiler_fixup
2727
from ..._modified import newer
2828
from ...compat import consolidate_linker_args
29-
from ...errors import CompileError, DistutilsExecError, LibError, LinkError
29+
from ...errors import DistutilsExecError
3030
from . import base
3131
from .base import gen_lib_options, gen_preprocess_options
32+
from .errors import (
33+
CompileError,
34+
LibError,
35+
LinkError,
36+
)
3237

3338
# XXX Things not currently handled:
3439
# * optimization/debug/warning flags; we just use whatever's in Python's

distutils/compilers/C/zos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
import os
1515

1616
from ... import sysconfig
17-
from ...errors import CompileError, DistutilsExecError
17+
from ...errors import DistutilsExecError
1818
from . import unix
19+
from .errors import CompileError
1920

2021
_cc_args = {
2122
'ibm-openxl': [

0 commit comments

Comments
 (0)