Skip to content

Commit

Permalink
Disallow repeat calls to .initialize in one place.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 10, 2022
1 parent 8813a17 commit 3e4c7a7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ def __init__(self, verbose=0, dry_run=0, force=0):
super().__init__(verbose, dry_run, force)
# target platform (.plat_name is consistent with 'bdist')
self.plat_name = None
self.initialized = False

def initialize(self, plat_name=None):
# multi-init means we would need to check platform same each time...
assert not self.initialized, "don't init multiple times"
def _repeat_call_error(plat_name=None):
raise AssertionError("repeat initialize not allowed")
self.initialize = _repeat_call_error
if plat_name is None:
plat_name = get_platform()
# sanity check for platforms to prevent obscure errors later.
Expand Down Expand Up @@ -309,8 +309,6 @@ def initialize(self, plat_name=None):
(CCompiler.SHARED_LIBRARY, True): self.ldflags_static_debug,
}

self.initialized = True

# -- Worker methods ------------------------------------------------

def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
Expand Down

0 comments on commit 3e4c7a7

Please sign in to comment.