473,573 Members | 5,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

test_socket.py failure


hi all,

Linux 2.4.28
Glibc 2.2.5
gcc 2.95.3
I'm new to Python.

I've compiled Python 2.4 from tar file.

When running 'make test' i'm getting a failure
in test_socket.

Running './python Lib/test/test_socket.py' yields:
=============== =============== =============== =============== ==========
ERROR: testGetServBy (__main__.Gener alModuleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib/test/test_socket.py" , line 330, in testGetServBy
port2 = socket.getservb yname(service)
error: service/proto not found

----------------------------------------------------------------------
Ran 58 tests in 3.826s

The value of 'service' was "daytime".

After much hand wringing, editing, and use of 'print'
statements i commented out line 330,
'# port2 = socket.getservb yname(service)' and replaced it
with the line 'port2 = port'.

Running './python Lib/test/test_socket.py' now yields:
testGetServBy (__main__.Gener alModuleTests) ... ok
Jul 18 '05 #1
10 3136
x2***@mailcity. com wrote:
hi all,

Linux 2.4.28
Glibc 2.2.5
gcc 2.95.3
I'm new to Python.

I've compiled Python 2.4 from tar file.

When running 'make test' i'm getting a failure
in test_socket.

Running './python Lib/test/test_socket.py' yields:
=============== =============== =============== =============== ==========
ERROR: testGetServBy (__main__.Gener alModuleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib/test/test_socket.py" , line 330, in testGetServBy
port2 = socket.getservb yname(service)
error: service/proto not found

----------------------------------------------------------------------
Ran 58 tests in 3.826s

The value of 'service' was "daytime".

After much hand wringing, editing, and use of 'print'
statements i commented out line 330,
'# port2 = socket.getservb yname(service)' and replaced it
with the line 'port2 = port'.

Running './python Lib/test/test_socket.py' now yields:
testGetServBy (__main__.Gener alModuleTests) ... ok
.
.
.
----------------------------------------------------------------------
Ran 58 tests in 5.181s

OK
Located the code for 'socket_getserv byname' in
'Modules/socketmodule.c' where the call to the glibc
function 'getservbyname' is made:

Py_BEGIN_ALLOW_ THREADS
sp = getservbyname(n ame, proto);
Py_END_ALLOW_TH READS
if (sp == NULL) {
PyErr_SetString (socket_error, "service/proto not found");
return NULL;
}
The only call of socket.getservb yname that failed was when
it was passed the single argument. Since the error message
"service/proto not found" seems to only be generated upon
failure of gibc's 'getservbyname' could it be that
'PyArg_ParseTup le(args, "s|s:getservbyn ame", &name, &proto)'
generates values for 'name' and/or 'proto' that cause the
failure?

My search for prior reports of failure at line 330 found
a mention of problems at line 331.

Well, at any rate, if someone could point me down the
correct path on this i would appreciate it.

Compiling from source requires you to indicate the features that you
want compiled in. Without thread support, sockets din't work, so it
looks like you need to configure threads in. IIRC you do this by editing
the Modules.? file.

regards
Steve
Jul 18 '05 #2
Steve Holden <st***@holdenwe b.com> wrote:
x2***@mailcity. com wrote:
hi all,

Linux 2.4.28
Glibc 2.2.5
gcc 2.95.3
I'm new to Python.

I've compiled Python 2.4 from tar file.

When running 'make test' i'm getting a failure
in test_socket.

Running './python Lib/test/test_socket.py' yields:
=============== =============== =============== =============== ==========
ERROR: testGetServBy (__main__.Gener alModuleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib/test/test_socket.py" , line 330, in testGetServBy
port2 = socket.getservb yname(service)
error: service/proto not found

----------------------------------------------------------------------
Ran 58 tests in 3.826s

The value of 'service' was "daytime".

After much hand wringing, editing, and use of 'print'
statements i commented out line 330,
'# port2 = socket.getservb yname(service)' and replaced it
with the line 'port2 = port'.

Running './python Lib/test/test_socket.py' now yields:
testGetServBy (__main__.Gener alModuleTests) ... ok
.
.
.
----------------------------------------------------------------------
Ran 58 tests in 5.181s

OK
Located the code for 'socket_getserv byname' in
'Modules/socketmodule.c' where the call to the glibc
function 'getservbyname' is made:

Py_BEGIN_ALLOW_ THREADS
sp = getservbyname(n ame, proto);
Py_END_ALLOW_TH READS
if (sp == NULL) {
PyErr_SetString (socket_error, "service/proto not found");
return NULL;
}
The only call of socket.getservb yname that failed was when
it was passed the single argument. Since the error message
"service/proto not found" seems to only be generated upon
failure of gibc's 'getservbyname' could it be that
'PyArg_ParseTup le(args, "s|s:getservbyn ame", &name, &proto)'
generates values for 'name' and/or 'proto' that cause the
failure?

My search for prior reports of failure at line 330 found
a mention of problems at line 331.

Well, at any rate, if someone could point me down the
correct path on this i would appreciate it.
Compiling from source requires you to indicate the features that you
want compiled in. Without thread support, sockets din't work, so it
looks like you need to configure threads in. IIRC you do this by editing
the Modules.? file.

regards
Steve


hi Steve,

Here's a cut down version of the compilation line for
socketmodule.c which contains the 'socket_getserv byname'
code:

gcc -pthread -DNDEBUG ...
-c /usr/src/Python-2.4/Modules/socketmodule.c
-o build/temp.linux-i686-2.4/socketmodule.o

Is '-pthread' the type of thread i need?

I'm still curious why only the call with one argument to
'socket.getserv byname' fails while the two other calls
which pass two arguments don't fail.

Any ideas?
pete jordan
x2164 at
mailcity com

--
............

Jul 18 '05 #3
x2***@mailcity. com wrote:
hi all,

Linux 2.4.28
Glibc 2.2.5
gcc 2.95.3
I'm new to Python.

I've compiled Python 2.4 from tar file.

When running 'make test' i'm getting a failure
in test_socket.


Two questions. First, what does the following code give when you run it at the
interactive prompt?:

Py> import socket
Py> socket.getservb yname('daytime' )
13

Second, is there an entry for 'daytime' in /etc/services?

Cheers,
Nick.

--
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #4
Nick Coghlan <nc******@iinet .net.au> wrote:
x2***@mailcity. com wrote:
hi all,

Linux 2.4.28
Glibc 2.2.5
gcc 2.95.3
I'm new to Python.

I've compiled Python 2.4 from tar file.

When running 'make test' i'm getting a failure
in test_socket.
Two questions. First, what does the following code give
when you run it at the
interactive prompt?: Py> import socket
Py> socket.getservb yname('daytime' )
13 Second, is there an entry for 'daytime' in /etc/services? Cheers,
Nick. --
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net


hi Nick,
At the interactive python prompt i did/got the following:

bash-2.04$ ./python
Python 2.4 (#1, Jan 29 2005, 10:31:35)
[GCC 2.95.3 20010315 (release)] on linux2
Type "help", "copyright" , "credits" or "license" for
more information.
import socket
socket.getservb yname('daytime' , 'tcp') 13

# The 13 looks ok but look what happen
# when i asked only for the service, like
# the line that fails in test_socket.
socket.getservb yname('daytime' ) Traceback (most recent call last):
File "<stdin>", line 1, in ?
socket.error: service/proto not found


From my /etc/services file:

daytime 13/tcp
daytime 13/udp
I was trying to use gdb to watch the function
socket_getservb yname, from Modules/socketmodule.c,
execute but i'm not sure how to set the gdb 'break' for
a function in a module that isn't imported at the time
i start python in gdb.

Hints welcome. ;-)
pete jordan
x2164 at
mail.city
--
............

Jul 18 '05 #5
x2***@mailcity. com wrote:
At the interactive python prompt i did/got the following:

bash-2.04$ ./python
Python 2.4 (#1, Jan 29 2005, 10:31:35)
[GCC 2.95.3 20010315 (release)] on linux2
Type "help", "copyright" , "credits" or "license" for
more information.
>>> import socket
>>> socket.getservb yname('daytime' , 'tcp')
13

# The 13 looks ok but look what happen
# when i asked only for the service, like
# the line that fails in test_socket.

>>> socket.getservb yname('daytime' )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
socket.error: service/proto not found
>>>


Hmm, when the second argument is omitted, the system call looks like:

getservbyname(" daytime", NULL);

Based on "man getservbyname" on my Linux PC, that should give the behaviour we
want - any protocol will match.

However:

Linux 2.6.4-52-default (Suse 9.1)
Glibc 2.3.3
gcc 3.3.3

So it may be that your older platform doesn't have this behaviour - I'd be very
interested in what 'man getservbyname' has to say.

Cheers,
Nick.

--
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #6
Nick Coghlan <nc******@iinet .net.au> wrote:
x2***@mailcity. com wrote:
At the interactive python prompt i did/got the following:

bash-2.04$ ./python
Python 2.4 (#1, Jan 29 2005, 10:31:35)
[GCC 2.95.3 20010315 (release)] on linux2
Type "help", "copyright" , "credits" or "license" for
more information.
>>> import socket
>>> socket.getservb yname('daytime' , 'tcp') 13

# The 13 looks ok but look what happen
# when i asked only for the service, like
# the line that fails in test_socket.
>>> socket.getservb yname('daytime' )

Traceback (most recent call last):
File "<stdin>", line 1, in ?
socket.error: service/proto not found
>>>

Hmm, when the second argument is omitted, the system call looks like: getservbyname(" daytime", NULL); Based on "man getservbyname" on my Linux PC, that should give
the behaviour we
want - any protocol will match. However: Linux 2.6.4-52-default (Suse 9.1)
Glibc 2.3.3
gcc 3.3.3 So it may be that your older platform doesn't have this
behaviour - I'd be very
interested in what 'man getservbyname' has to say. Cheers,
Nick. --
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net


hey Nick,

Just took a look at the man page for getservbyname on this
system and it doesn't mention passing NULL as the second
argument. The pertinents: ;-)

Linux kernel 2.6.10
Glibc 2.2.5
gcc 2.95.3

I'd say your probably right about there being a difference
in the behaviour of getservbyname between libc 2.2.5 and
and libc-2.3.3 given the differences in man pages and
observed return values. I'll try and compare the libcs'
getservbyname codes and let you know a little later in
the day.

I wonder if the developers wanted to tie the python source
code so closely to a glibc version and possibly gnu-libc
specific?
pete jordan
x2164 at mailcityDOTcom
miami, florida
--
............

Jul 18 '05 #7
x2***@mailcity. com wrote:
Nick Coghlan <nc******@iinet .net.au> wrote:
Hmm, when the second argument is omitted, the system call looks like:

getservbyname(" daytime", NULL);

Based on "man getservbyname" on my Linux PC, that should give
the behaviour we
want - any protocol will match.

However:

Linux 2.6.4-52-default (Suse 9.1)
Glibc 2.3.3
gcc 3.3.3

So it may be that your older platform doesn't have this
behaviour - I'd be very
interested in what 'man getservbyname' has to say.
Just took a look at the man page for getservbyname on this
system and it doesn't mention passing NULL as the second
argument. The pertinents: ;-)

Linux kernel 2.6.10
Glibc 2.2.5
gcc 2.95.3


Just to confuse the matter more, on my system the man page mentions
passing NULL as the second argument and it works. Alas:
SuSE 7.3
Kernel 2.4.29 (vanilla)
Glibc 2.2.4 (older than yours)
gcc 2.95.3
I'd say your probably right about there being a difference
in the behaviour of getservbyname between libc 2.2.5 and
and libc-2.3.3 given the differences in man pages and
observed return values. I'll try and compare the libcs'
getservbyname codes and let you know a little later in
the day.

I wonder if the developers wanted to tie the python source
code so closely to a glibc version and possibly gnu-libc
specific?


Perhaps SuSE did patch the glibc...

Saluton
Marc
Jul 18 '05 #8
Marc Christiansen <to***@jupiter. solar-empire.de> wrote:
x2***@mailcity. com wrote:
Nick Coghlan <nc******@iinet .net.au> wrote:
Hmm, when the second argument is omitted, the system call looks like:

getservbyname(" daytime", NULL);

Based on "man getservbyname" on my Linux PC, that should give
the behaviour we
want - any protocol will match.

However:

Linux 2.6.4-52-default (Suse 9.1)
Glibc 2.3.3
gcc 3.3.3

So it may be that your older platform doesn't have this
behaviour - I'd be very
interested in what 'man getservbyname' has to say.
Just took a look at the man page for getservbyname on this
system and it doesn't mention passing NULL as the second
argument. The pertinents: ;-)

Linux kernel 2.6.10
Glibc 2.2.5
gcc 2.95.3 Just to confuse the matter more, on my system the man page mentions
passing NULL as the second argument and it works. Alas:
SuSE 7.3
Kernel 2.4.29 (vanilla)
Glibc 2.2.4 (older than yours)
gcc 2.95.3 I'd say your probably right about there being a difference
in the behaviour of getservbyname between libc 2.2.5 and
and libc-2.3.3 given the differences in man pages and
observed return values. I'll try and compare the libcs'
getservbyname codes and let you know a little later in
the day.

I wonder if the developers wanted to tie the python source
code so closely to a glibc version and possibly gnu-libc
specific?

Perhaps SuSE did patch the glibc... Saluton
Marc


hey Marc
Oh man, not another problem that's just happening to
me, again. :-)

We all are still talking about python 2.4 aren't we? I'm
really running out of options on this.

My manual page for getservbyname is dated "22 April 1996"
and i think that it wasn't installed by glibc-2.2.5. The
info page for getservbyname which was installed by 2.2.5
doesn't mention being able to pass NULL as a 'PROTO'
argument.

As for my saying above that i would take a look at the
libcs' code for getservbyname, well, let's just say
i won't be bantering about that idea so readily anytime
soon. :-)

What i believe happens in glibc-2.3.3 is that getservbyname
is generated by two files: inet/getsrvbynm.c which contains
a number of '#define's that then '#include's the file
nss/getXXbyYY.c which is sort of a template function that
the '#define's fill out. If your use to reading it
nss/getXXbyYY.c probably is easy reading, but, for ego's sake,
let's just say that i'm not use to reading it. There's
also getsrvbynm_r.c and getXXbyYY_r.c for the reentrant
versions of getservbyname plus some references to nss and
nis versions of getservbyname. Of course its also possilble
that where i said "What i believe happens" at the beginning
of this paragraph could be read as "I'm confused about what
happens" and i don't mean that as critic of glibc.

Marc, it is possible that there was a change between
glibc-2.2.4 and 2.2.5 that would account for the
difference in behaviour. I think i'll write a little
test program in C to check out getservbyname's return
values in a little more controled environment. I'll
post the results tomorrow.
pete jordan
x2164 mailcity com


--
............

Jul 18 '05 #9
Nick Coghlan <nc******@iinet .net.au> wrote:
x2***@mailcity. com wrote:
Marc, it is possible that there was a change between
glibc-2.2.4 and 2.2.5 that would account for the
difference in behaviour. I think i'll write a little
test program in C to check out getservbyname's return
values in a little more controled environment. I'll
post the results tomorrow.
The other question is which C library Python is actually
using on your system.
Maybe it's picking up whatever installed the funky man page
which doesn't
mention NULL proto arguments. So, find your Python 2.4 binary and run "ldd python24" to
see which shared C
library it is linking to. For me, it's /lib/tls/libc.so.6. Running that library directly
prints out the
message about GNU C library 2.3.3.

hey Nick,
The man pages are probably from orignal system installation
so i used your ldd technique which says that the python
executable was compiled against glibc-2.2.5.

I'm going to check the diff for 2.2.4-2.2.5 and look for
anything getservbyname related.

Below i'm including the source code for a little
program to exercise getservbyname. On this system
if 'NULL' is passed as the protocal then 'NULL' is
returned.

I wonder if writing some code around the call to
getservbyname in Modules/socketmodule.c to test
for a call with the NULL argument would be
appropriate. Could you show the output from my
included program when NULL is passed as
an argument? Probably would be good to know
what the call returns on your system before
trying to get mine to mimic it.
Ok, back to grep'ing.
pete jordan
x2164 mailcity com


/*
* This program just test what happens when getservbyname
* is passed a NULL pointer argument for the name and proto
* paramenters.
*
* The compilation line i used:
*
* gcc getserv.c -o getserv
*
* and just type 'getserv' at a prompt.
*
* Just pass 'service name, protocol name' to
* 'get_print' to check if combination is found.
*/
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
void get_print( const char *, const char * );

int main()
{
get_print( "daytime", "tcp" );
get_print( "daytime", "udp" );
get_print( "daytime", NULL );
get_print( NULL, "tcp" );
get_print( NULL, NULL );
get_print( "ithkl", "tcp" );
get_print( "echo", "ddp" );

return ;
}

void get_print( const char *name, const char *proto )
{
struct servent *result = NULL ;

result = getservbyname( name, proto );

printf( "\n getservbyname call: getservbyname( %s , %s ) \n",
name, proto );

printf(" getservbyname returned:\n");

if ( result == NULL )
printf("\t\t\t NULL - end of 'services' file reached or\n"
"\t\t\t error occured.\n\n");
else
{
printf( "\t\t\t s_name = %s \n", result->s_name );
printf( "\t\t\t s_port = %d \n", ntohs(result->s_port) );
printf( "\t\t\t s_proto = %s \n", result->s_proto );
printf( "\n" );
}

}

Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3743
by: Damaji Jambhale | last post by:
COMException: Catostrphic failure When I added a "dll" reference in the web project. I was able to instantiate the class OK. But when I tried to set the properties, it failed with "COMException: Catostrphic failure". Any idea? Thanks.
2
3080
by: JustaCowboy | last post by:
Greetings, I am seeking information related to this subject. BOL suggests backing up the active transaction log immediately after a failure, so that the backup can be used in a recovery scenario if necessary. This is the relevant text from BOL "Transaction Log Backup": ----// The transaction log backup created at 8:00 P.M. contains...
4
8108
by: J. Marshall Latham | last post by:
I have written an ASP.NET web app in C# that is trying to connect to a database using OleDb. I put code in a dll that uses another dll to create a connection object (and open it if requested) to send back to the web app to connect to the database. I am getting the following error when I change anything in my web app and recompile....
5
5549
by: Ron Louzon | last post by:
I have some C++ code that uses the CSingleLock( CCriticalSection *) constructor. In visual C++ 6.0, this code compiles and runs fine in both Debug and release modes. However, in Visual Studio .Net, when I run this code I get an Assertion failure. The error appears to be exactly the same as that seen with CSingleLock in VC++ version 4.0. I...
8
10154
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() { printf("Hey,you're been attacked.\n");
0
2637
by: Marty Cruise | last post by:
I successfully deploy my application to 20 domain users. Only one new user is giving me a problem, although he can access all domain resources. When he clicks the installation link on the publish page, Framework 2.0 installs successfully, but then the application installation fails during the "Verifying Application Requirements" process. ...
66
3578
by: Johan Tibell | last post by:
I've written a piece of code that uses sockets a lot (I know that sockets aren't portable C, this is not a question about sockets per se). Much of my code ended up looking like this: if (function(socket, args) == -1) { perror("function"); exit(EXIT_FAILURE); } I feel that the ifs destroy the readability of my code. Would it be
1
1861
by: vierling | last post by:
As a digibetic I don't know how to repair Jscript failure (run time failure rule 7 and 5): indicating : object is expected. This is what MS Script Editor tells me, but it doesnot tell me how to repair. It shows a page of Jscript, though, whith a yellow arrow indicating the 'locus delicti' or failure spot: after the Jscript hereunder (unfortunately...
8
3120
by: =?Utf-8?B?TWFyaw==?= | last post by:
We've got a wierd failure happening on just one machine. One part of our product uses a 3rd party search implementation (dtSearch). DtSearch has a native core (dten600.dll), late-bound, and a managed wrapper (dtSearchNetApi2.dll). For reasons unknown our build and msi packaging process includes dtSearchNetApi2.dll but not dten600.dll in...
0
7707
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8037
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3743
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1048
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.