Skip to content
Open
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
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ def get_compiler_settings(version_str):

# Homebrew installs odbc_config
pipe = os.popen('odbc_config --cflags --libs 2>/dev/null')
cflags, ldflags = pipe.readlines()
exit_status = pipe.close()
try:
cflags, ldflags = pipe.readlines()
except ValueError: # The command failed
cflags, ldflags = '', ''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the patch is setting cflags and ldflags to empty strings in the except block because you want to guard against another exception in the case in which we end up in the exit_status is None block. Presumably that would happen if odbc_config was found but produced malformed output for some reason. In that case wouldn't it be preferable to at least warn the user about the problem, if not abort the script altogether with an appropriate error message? You could set cflags and ldflags to None and then test them in the if exit_status is None` block.

finally:
exit_status = pipe.close()

if exit_status is None:
settings['extra_compile_args'].extend(shlex.split(cflags))
Expand Down