Skip to content

Commit 3e4c7a7

Browse files
committed
Disallow repeat calls to .initialize in one place.
1 parent 8813a17 commit 3e4c7a7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

distutils/_msvccompiler.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ def __init__(self, verbose=0, dry_run=0, force=0):
222222
super().__init__(verbose, dry_run, force)
223223
# target platform (.plat_name is consistent with 'bdist')
224224
self.plat_name = None
225-
self.initialized = False
226225

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

312-
self.initialized = True
313-
314312
# -- Worker methods ------------------------------------------------
315313

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

0 commit comments

Comments
 (0)