[tor-commits] [nyx/master] Avoid os.putenv calls on FreeBSD

atagar at torproject.org atagar at torproject.org
Tue Oct 31 17:44:08 UTC 2017


commit f4cfa06035a92c888588d1cb9c90b9ccc9836b80
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Oct 31 10:42:31 2017 -0700

    Avoid os.putenv calls on FreeBSD
    
    Turns out even when we suppress the exceptions it causes the interpreter to
    print to stdout. Lets just avoid these calls entirely on FreeBSD. Dropping the
    catch clauses since we were only doing this due to FreeBSD.
---
 nyx/starter.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/nyx/starter.py b/nyx/starter.py
index 2532a4a..62c8287 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -87,15 +87,14 @@ def main(config):
   _use_unicode()
   _set_process_name()
 
-  try:
-    os.putenv('LANG', 'C')  # make subcommands (ps, netstat, etc) provide english results
-  except OSError:
-    pass
+  # These os.putenv calls fail on FreeBSD, and even attempting causes python to
+  # print the following to stdout...
+  #
+  #   nyx: environment corrupt; missing value for
 
-  try:
+  if not stem.util.system.is_bsd():
+    os.putenv('LANG', 'C')  # make subcommands (ps, netstat, etc) provide english results
     os.putenv('ESCDELAY', '0')  # make 'esc' take effect right away
-  except OSError:
-    pass
 
   try:
     nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False)



More information about the tor-commits mailing list