Skip to content

Commit

Permalink
bpo-45101: Add consistency in usage message IO between 2 versions of …
Browse files Browse the repository at this point in the history
…python-config (pythonGH-28162)

On --help output to stdout.
On error output to stderr.
  • Loading branch information
kiendang authored and adorilson committed Mar 25, 2024
1 parent afb5931 commit 815f870
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add consistency in usage message IO between 2 versions of python-config.
3 changes: 2 additions & 1 deletion Misc/python-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',

def exit_with_usage(code=1):
print("Usage: {0} [{1}]".format(
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr)
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)),
file=sys.stdout if code == 0 else sys.stderr)
sys.exit(code)

try:
Expand Down
7 changes: 6 additions & 1 deletion Misc/python-config.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

exit_with_usage ()
{
echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
local USAGE="Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
if [[ "$1" -eq 0 ]]; then
echo "$USAGE"
else
echo "$USAGE" >&2
fi
exit $1
}

Expand Down

0 comments on commit 815f870

Please sign in to comment.