Skip to content

Commit

Permalink
Use -n option suggested by Ed
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Sep 6, 2023
1 parent 43499b7 commit 410b2d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lib/test/support/socket_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def _get_sysctl(name):
except KeyError:
pass

cmd = ['sysctl', name]
# At least Linux and FreeBSD support the "-n" option
cmd = ['sysctl', '-n', name]
proc = subprocess.run(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand All @@ -305,8 +306,7 @@ def _get_sysctl(name):

# Parse 'net.inet.tcp.blackhole: 0\n' to get '0'
try:
value = output.rstrip().split(':', 1)[-1].strip()
value = int(value)
value = int(output.strip())
except Exception as exc:
support.print_warning(f'Failed to parse {' '.join(cmd)!r} '
f'command output {output!r}: {exc!r}')
Expand Down

0 comments on commit 410b2d3

Please sign in to comment.