Using !command gives popen3 deprecated warning on python 2.6.4

Bug #488061 reported by Pim Schellart
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
Medium
Fernando Perez

Bug Description

The subprocess module replaces the following older modules which are marked deprecated as of python 2.6.4:
os.system
os.spawn*
os.popen*
popen2.*
commands.*

At the moment using list=!command in IPython gives a deprecation warning for popen3.
I attached a patch which updates genutils (in utils) to use subprocess instead.
Someone should probably go over the rest of the code and replace all occurences of the above modules by their subprocess replacements.

Related branches

Revision history for this message
Pim Schellart (pschella) wrote :
Changed in ipython:
assignee: nobody → Fernando Perez (fdo.perez)
milestone: none → 0.11
status: New → Fix Committed
Revision history for this message
Fernando Perez (fdo.perez) wrote :

Thanks! Fix committed to trunk-dev.

While I fully agree that we should update the rest of the codebase, it's annoying to do because the subp interface is so awful. The fact that

pin,pout,perr = os.popen3(cmd)

becomes:

        p = subprocess.Popen(cmd, shell=True,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             close_fds=True)
        pin, pout, perr = (p.stdin, p.stdout, p.stderr)

is just horrible. I feel that subprocess was left unfinished, with all the useful one-liners from os.popen*, commands.* and os.system not being provided. It would be great if someone could go back to subp and simply add a bunch of easy-to-remember short functions of this kind, built on top of the (perfectly good) underlying library.

Anyway, this is just a semi-rant for why at least I haven't done the cleanup. If you use subp a lot and wan to whip out such a little utility library on top of it, we'd be happy to carry it!

Thanks for the report/patch.

Changed in ipython:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.