os.system question

Wojtek Walczak gminick at nie.ma.takiego.adresu.w.sieci.pl
Wed Aug 13 14:50:38 EDT 2008


Dnia Tue, 12 Aug 2008 23:38:56 -0700 (PDT), Asun Friere napisa³(a):

> I note 3.0 runs os.popen without complaint (and had thought to mention
> that in my previous).  Right now I'm wondering whether I should
> install the beta 2.6 to see whether Wotjek is pulling our leg or
> not. :)

:) Checked it to make sure.

Python 2.6b2 (r26b2:65082, Aug 13 2008, 01:12:28)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import popen2
__main__:1: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
>>> import os
>>> print os.popen('whoami').read()
gminick

>>> print os.popen2('whoami')[1].read()
gminick

>>> print os.popen2('whoami')[0].read()
__main__:1: DeprecationWarning: os.popen2 is deprecated. Use the subprocess module.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 9] Bad file descriptor
>>>

The strange thing is that os.popen2 prints the deprecation warning
only when it's called inappropriately. Got to investigate it further.

os.popen won't return any deprecation warning in Py2.6beta2 probably
because it is defined in Lib/platform.py and not in Lib/os.py and
I guess that somebody has forgotten to add the warnings in there.

-- 
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list