Ticket #7967: 7967_popen3.patch

File 7967_popen3.patch, 1.7 KB (added by wjp, 11 years ago)
  • sage/misc/hg.py

    # HG changeset patch
    # User Willem Jan Palenstijn <wjp@usecode.org>
    # Date 1263754092 28800
    # Node ID 06cb5f58b70b8d9f0c5d0fb6be7e52cd475812b9
    # Parent  5ea2ef57e731acc62b1727a3ea4e55a567b3f920
    #7967: replace os.popen3 by subprocess.Popen
    
    diff -r 5ea2ef57e731 -r 06cb5f58b70b sage/misc/hg.py
    a b  
    4343from   misc   import tmp_filename, branch_current_hg, embedded
    4444from   remote_file import get_remote_file as get_remote_file0
    4545from   sage.server.misc import print_open_msg
     46from   subprocess import Popen
    4647import re
    4748
    4849sage_trac_re = re.compile('http[s]?://(sagetrac\.org|trac\.sagemath\.org)/sage_trac/attachment/ticket/[0-9]+/.*\.(patch|hg)')
     
    213214       
    214215        -  ``interactive`` - If True, runs using os.system, so
    215216           user can interactively interact with hg, i.e., this is needed when
    216            you record changes because the editor pops up. If False, popen3 is
     217           you record changes because the editor pops up. If False, Popen is
    217218           used to launch hg as a subprocess.
    218219       
    219220       
     
    237238            e = os.system(s)
    238239            return e
    239240        else:
    240             x = os.popen3(s)
    241             x[0].close()
    242             out = x[1].read()
    243             err = x[2].read()
     241            from subprocess import PIPE
     242            x = Popen(s, shell=True,
     243                      stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
     244            x.stdin.close()
     245            out = x.stdout.read()
     246            err = x.stderr.read()
    244247            return out, err
    245248
    246249    def serve(self, port=8200, address='localhost',