Ignore:
Timestamp:
02/19/13 14:40:13 (14 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fix invalid stdout/stderr streams on windows when running without a console.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/main.py

    r11299 r11339  
    4242    except NameError: 
    4343        return False 
     44 
     45 
     46def fix_win_pythonw_std_stream(): 
     47    """ 
     48    On windows when running without a console (using pythonw.exe) the 
     49    std[err|out] file descriptors are invalid and start throwing exceptions 
     50    when their buffer is flushed (`http://bugs.python.org/issue706263`_) 
     51 
     52    """ 
     53    if sys.platform == "win32" and \ 
     54            os.path.basename(sys.executable) == "pythonw.exe": 
     55        if sys.stdout.fileno() < 0: 
     56            sys.stdout = open(os.devnull, "wb") 
     57        if sys.stderr.fileno() < 0: 
     58            sys.stderr = open(os.devnull, "wb") 
    4459 
    4560 
     
    91106 
    92107    logging.basicConfig(level=levels[options.log_level]) 
     108 
     109    fix_win_pythonw_std_stream() 
    93110 
    94111    log.info("Starting 'Orange Canvas' application.") 
Note: See TracChangeset for help on using the changeset viewer.