Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def finalize_options(self) -> None: # noqa: C901
if self.undef:
self.undef = self.undef.split(',')

if self.swig_opts is None:
self.swig_opts = []
else:
if isinstance(self.swig_opts, str):
self.swig_opts = self.swig_opts.split(' ')
elif self.swig_opts is None:
self.swig_opts = []

# Finally add the user include and library directories if requested
if self.user:
Expand Down
6 changes: 6 additions & 0 deletions distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ def test_finalize_options(self):
cmd.finalize_options()
assert cmd.swig_opts == ['1', '2']

# make sure finalize_options() can be called more than once
# without raising an exception
cmd = self.build_ext(dist)
cmd.finalize_options()
cmd.finalize_options()

def test_check_extensions_list(self):
dist = Distribution()
cmd = self.build_ext(dist)
Expand Down
2 changes: 2 additions & 0 deletions newsfragments/385.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a bug where calling ``distutils.build_ext.finalize_options`` more than once
would raise an exception.