[Python-bugs-list] [Bug #110691] popen2 and socket. (PR#53)

noreply@sourceforge.net noreply@sourceforge.net
Wed, 23 Aug 2000 11:16:16 -0700


Bug #110691, was updated on 2000-Jul-31 21:15
Here is a current snapshot of the bug.

Project: Python
Category: Modules
Status: Closed
Resolution: None
Bug Group: Not a Bug
Priority: 5
Summary: popen2 and socket. (PR#53)

Details: Jitterbug-Id: 53
Submitted-By: tm@funcom.com
Date: Mon, 16 Aug 1999 09:58:05 -0400 (EDT)
Version: latest from CVS
OS: Linux 2.2.10 libc5.3.12


When doing make test on the latest(as of 16 Aug 1999) python version, the 
popen2 and socket tests fail. 

output from test_popen2:
testing popen2...
Traceback (innermost last):
  File "test_popen2.py", line 16, in ?
    main()
  File "test_popen2.py", line 14, in main
    popen2._test()
  File "../../Lib/popen2.py", line 84, in _test
    r, w = popen2('cat')
  File "../../Lib/popen2.py", line 73, in popen2
    inst = Popen3(cmd, 0, bufsize)
  File "../../Lib/popen2.py", line 24, in __init__
    os.close(0)
OSError: [Errno 9] Bad file number
Traceback (innermost last):
  File "test_popen2.py", line 16, in ?
    main()
  File "test_popen2.py", line 14, in main
    popen2._test()
  File "../../Lib/popen2.py", line 87, in _test
    assert r.read() == teststr
AssertionError

output from test_socket:
socket.error
Traceback (innermost last):
  File "test_socket.py", line 71, in ?
    ip = socket.gethostbyname(hostname)
socket.error: host not found




====================================================================
Audit trail:
Mon Aug 16 10:13:57 1999	guido	changed notes
Mon Aug 16 10:13:57 1999	guido	moved from incoming to notabug
Mon Aug 16 10:15:22 1999	guido	sent reply 1
Mon Aug 16 13:33:03 1999	guido	changed notes
Mon Aug 16 14:24:25 1999	guido	changed notes
Mon Aug 16 14:24:25 1999	guido	moved from notabug to open
Wed Jul 26 18:27:01 2000	guido	resent 53.reply.1

Follow-Ups:

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Guido van Rossum <bugs-py@python.org>
Subject: Re: popen2 and socket. (PR#53)
Date: Mon Aug 16 10:15:22 1999

This is not a Python bug.
Your network environment has not been set up properly.
Don't worry unless you want to use sockets
(in that case you have to figure out how to set
up your Linux networking; Python will automatically follow).

-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Terje Malmedal <tm@funcom.com>
Subject: Re: popen2 and socket. (PR#53)
Date: Mon, 16 Aug 1999 16:41:58 +0200


[Guido van Rossum]
> This is not a Python bug.
> Your network environment has not been set up properly.

Yes it is. The machine is connected to the internet. Everything else,
including Apache and Perl are able to use the network.

I forgot to mention that Python 1.5.1 works with no problems. 

> Don't worry unless you want to use sockets
> (in that case you have to figure out how to set
> up your Linux networking; Python will automatically follow).


-- 
 - Terje
tm@funcom.com

-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Guido van Rossum <guido@CNRI.Reston.VA.US>
Subject: Re: [Python-bugs-list] Re: popen2 and socket. (PR#53)
Date: Mon, 16 Aug 1999 11:36:25 -0400

> [Guido van Rossum]
> > This is not a Python bug.
> > Your network environment has not been set up properly.
> 
> Yes it is. The machine is connected to the internet. Everything else,
> including Apache and Perl are able to use the network.
> 
> I forgot to mention that Python 1.5.1 works with no problems. 

The specific problem is with the DNS.  The failing line in
test_socket.py checks that the DNS lookup for the result of
gethostname() succeeds.  In your case, it fails.  There are tons of
possible reasons why it would fail: perhaps gethostname() returns a
host without a domain, or perhaps your hostname isn't registered in
your DNS.  You may be able to fix it by editing /etc/hosts.

If (as you say) the rest of the network works fine, you don't have to
worry about the two failing tests.

--Guido van Rossum (home page: http://www.python.org/~guido/)

-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Terje Malmedal <tm@funcom.com>
Subject: Re: [Python-bugs-list] Re: popen2 and socket. (PR#53)
Date: Mon, 16 Aug 1999 19:17:59 +0200


[Guido van Rossum]
>> [Guido van Rossum]
>> > This is not a Python bug.
>> > Your network environment has not been set up properly.
>> 
>> Yes it is. The machine is connected to the internet. Everything else,
>> including Apache and Perl are able to use the network.
>> 
>> I forgot to mention that Python 1.5.1 works with no problems. 

> The specific problem is with the DNS.  The failing line in
> test_socket.py checks that the DNS lookup for the result of
> gethostname() succeeds.  In your case, it fails.  There are tons of
> possible reasons why it would fail: perhaps gethostname() returns a
> host without a domain, or perhaps your hostname isn't registered in
> your DNS.  You may be able to fix it by editing /etc/hosts.

Something else is going on, I built python 1.5.1 and 1.5.2 on the
exact same machine with exact same configure statements:

Python 1.5.2 (#9, Aug 16 1999, 19:08:25)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import socket
>>> socket.gethostbyname("cnn.com")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
socket.error: host not found
>>>

Python 1.5.1 (#4, Aug 16 1999, 18:15:50)  [GCC egcs-2.91.66 19990314 (e on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import socket
>>> socket.gethostbyname("cnn.com")
'207.25.71.12'
>>>

gethostbyname("localhost") gives the same result, works in 1.5.1, but
not in 1.5.2.

-- 
 - Terje
tm@funcom.com

-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Guido van Rossum <guido@CNRI.Reston.VA.US>
Subject: Re: [Python-bugs-list] Re: popen2 and socket. (PR#53)
Date: Mon, 16 Aug 1999 13:21:56 -0400

> Something else is going on, I built python 1.5.1 and 1.5.2 on the
> exact same machine with exact same configure statements:
> 
> Python 1.5.2 (#9, Aug 16 1999, 19:08:25)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2  on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import socket
> >>> socket.gethostbyname("cnn.com")
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> socket.error: host not found
> >>>
> 
> Python 1.5.1 (#4, Aug 16 1999, 18:15:50)  [GCC egcs-2.91.66 19990314 (e on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import socket
> >>> socket.gethostbyname("cnn.com")
> '207.25.71.12'
> >>>
> 
> gethostbyname("localhost") gives the same result, works in 1.5.1, but
> not in 1.5.2.

Hm, all this works fine on any machine I can test it on, and I haven't
heard this problem reported before.  So I speculate that somehow your
Python 1.5.2 build is broken.  I don't know how you help you any
further; perhaps you can try the newsgroup -- or just download Oliver
Andrich's RPMs...

--Guido van Rossum (home page: http://www.python.org/~guido/)


-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Terje Malmedal <tm@funcom.com>
Subject: Re: [Python-bugs-list] Re: popen2 and socket. (PR#53)
Date: Mon, 16 Aug 1999 20:17:39 +0200


[Guido van Rossum]
>> Something else is going on, I built python 1.5.1 and 1.5.2 on the
>> exact same machine with exact same configure statements:
>> 
>> Python 1.5.2 (#9, Aug 16 1999, 19:08:25)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2  on linux2
>> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>> >>> import socket
>> >>> socket.gethostbyname("cnn.com")
>> Traceback (innermost last):
>> File "<stdin>", line 1, in ?
>> socket.error: host not found
>> >>>
>> 
>> Python 1.5.1 (#4, Aug 16 1999, 18:15:50)  [GCC egcs-2.91.66 19990314 (e on linux2
>> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>> >>> import socket
>> >>> socket.gethostbyname("cnn.com")
>> '207.25.71.12'
>> >>>
>> 
>> gethostbyname("localhost") gives the same result, works in 1.5.1, but
>> not in 1.5.2.

> Hm, all this works fine on any machine I can test it on, and I haven't
> heard this problem reported before.  So I speculate that somehow your
> Python 1.5.2 build is broken.  I don't know how you help you any
> further; perhaps you can try the newsgroup -- or just download Oliver
> Andrich's RPMs...

I finally found it, in socketmodule.c O replaced this: 

#elif defined(linux)
#define HAVE_GETHOSTBYNAME_R_6_ARG
#else

with this: 

#elif defined(linux)
#define HAVE_GETHOSTBYNAME_R_5_ARG
#else

And everything worked. Strange that nobody else has noticed this,
maybe it's a libc versus glibc thing or something.

Anyway, thanks for your time. 

-- 
 - Terje
tm@funcom.com

-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
From: Guido van Rossum <guido@CNRI.Reston.VA.US>
Subject: Re: [Python-bugs-list] Re: popen2 and socket. (PR#53)
Date: Mon, 16 Aug 1999 14:22:49 -0400

> I finally found it, in socketmodule.c O replaced this: 
> 
> #elif defined(linux)
> #define HAVE_GETHOSTBYNAME_R_6_ARG
> #else
> 
> with this: 
> 
> #elif defined(linux)
> #define HAVE_GETHOSTBYNAME_R_5_ARG
> #else
> 
> And everything worked. Strange that nobody else has noticed this,
> maybe it's a libc versus glibc thing or something.
> 
> Anyway, thanks for your time. 

Ah, thanks!  As you say, this is probably dependent on your libc
version.  A better solution should be found, really...  I'll mark the
bug report as "open".

--Guido van Rossum (home page: http://www.python.org/~guido/)

-------------------------------------------------------

Date: 2000-Aug-01 21:02
By: none

Comment:
His Linux has a 5-arg gethostbyname() instead of a 6-arg gethostbyname().
This should really be determined in a more foolproof way in the configure
script!
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=110691&group_id=5470