Skip to content

Commit

Permalink
In compiler package, rely on compiler errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 6, 2024
1 parent eaaa82f commit 0833343
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
10 changes: 6 additions & 4 deletions distutils/compilers/C/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
from ..._modified import newer_group
from ...dir_util import mkpath
from ...errors import (
CompileError,
DistutilsModuleError,
DistutilsPlatformError,
LinkError,
UnknownFileError,
)
from ...file_util import move_file
from ...spawn import spawn
from ...util import execute, is_mingw, split_quoted
from .errors import (
CompileError,
LinkError,
UnknownFileType,
)


class Compiler:
Expand Down Expand Up @@ -974,7 +976,7 @@ def _make_out_path(self, output_dir, strip_dir, src_name):
try:
new_ext = self.out_extensions[ext]
except LookupError:
raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
raise UnknownFileType(f"unknown file type '{ext}' (from '{src_name}')")
if strip_dir:
base = os.path.basename(base)
return os.path.join(output_dir, base + new_ext)
Expand Down
12 changes: 7 additions & 5 deletions distutils/compilers/C/borland.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
from ..._log import log
from ..._modified import newer
from ...errors import (
CompileError,
DistutilsExecError,
LibError,
LinkError,
UnknownFileError,
)
from ...file_util import write_file
from . import base
from .base import gen_preprocess_options
from .errors import (
CompileError,
LibError,
LinkError,
UnknownFileType,
)

warnings.warn(
"bcppcompiler is deprecated and slated to be removed "
Expand Down Expand Up @@ -347,7 +349,7 @@ def object_filenames(self, source_filenames, strip_dir=False, output_dir=''):
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
(base, ext) = os.path.splitext(os.path.normcase(src_name))
if ext not in (self.src_extensions + ['.rc', '.res']):
raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
raise UnknownFileType(f"unknown file type '{ext}' (from '{src_name}')")
if strip_dir:
base = os.path.basename(base)
if ext == '.res':
Expand Down
8 changes: 5 additions & 3 deletions distutils/compilers/C/cygwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
from subprocess import check_output

from ...errors import (
CCompilerError,
CompileError,
DistutilsExecError,
DistutilsPlatformError,
)
from ...file_util import write_file
from ...version import LooseVersion, suppress_known_deprecation
from . import unix
from .errors import (
CompileError,
Error,
)


def get_msvcr():
Expand Down Expand Up @@ -246,7 +248,7 @@ def __init__(self, verbose=False, dry_run=False, force=False):
shared_option = "-shared"

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

self.set_executables(
compiler=f'{self.cc} -O -Wall',
Expand Down
8 changes: 5 additions & 3 deletions distutils/compilers/C/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@

from ..._log import log
from ...errors import (
CompileError,
DistutilsExecError,
DistutilsPlatformError,
LibError,
LinkError,
)
from ...util import get_host_platform, get_platform
from . import base
from .base import gen_lib_options
from .errors import (
CompileError,
LibError,
LinkError,
)


def _find_vc2015():
Expand Down
7 changes: 6 additions & 1 deletion distutils/compilers/C/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@
from ..._macos_compat import compiler_fixup
from ..._modified import newer
from ...compat import consolidate_linker_args
from ...errors import CompileError, DistutilsExecError, LibError, LinkError
from ...errors import DistutilsExecError
from . import base
from .base import gen_lib_options, gen_preprocess_options
from .errors import (
CompileError,
LibError,
LinkError,
)

# XXX Things not currently handled:
# * optimization/debug/warning flags; we just use whatever's in Python's
Expand Down
3 changes: 2 additions & 1 deletion distutils/compilers/C/zos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import os

from ... import sysconfig
from ...errors import CompileError, DistutilsExecError
from ...errors import DistutilsExecError
from . import unix
from .errors import CompileError

_cc_args = {
'ibm-openxl': [
Expand Down

0 comments on commit 0833343

Please sign in to comment.