====================== ============================ ==================== />错误:testGetServBy(__ main __。GeneralModuleTests) ------------------------------------ ---------------------------------- Traceback(最近一次电话会议):文件Lib / test / test_socket.py,第330行,在testGetServBy中 port2 = socket.getservbyname(服务)错误:service / proto not found - -------------------------------------------------- ------------------ 在3.826s中进行58次测试 服务的价值是白天。 经过多次手工拧紧,编辑和使用''print''语句后,我注释掉第330行,''#port2 = socket.getservbyname(service)' '并用''port2 = port''替换它。 运行''。/ python Lib / test / test_socket.py''现在产生: testGetServBy(__ main __。GeneralModuleTests)... ok 。。。 ------------------ -------------------------------------------------- - 在5.181s中进行58次测试 OK 在''Modules / socketmodule.c中找到''socket_getservbyname''的代码''glibc 函数''getservbyname''的调用是: Py_BEGIN_ALLOW_THREADS sp = getservbyname(name,proto); Py_END_ALLOW_THREADS if(sp == NULL){ PyErr_SetString(socket_error,service / proto not found); 返回NULL; } 唯一一次失败的socket.getservbyname调用是它传递了单个参数。由于错误消息service / proto not found似乎只是在gibc'''getservbyname'失败后才会生成'可能是那个'/'''PyArg_ParseTuple(args," s | s:getservbyname",& name,& proto)''为''name''和/或'proto''生成导致失败的值? 我在线搜索先前的失败报告330发现在第331行提到了问题。 好吧,无论如何,如果有人能指出我正确的道路,我会很感激。 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__.GeneralModuleTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "Lib/test/test_socket.py", line 330, in testGetServBy port2 = socket.getservbyname(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.getservbyname(service)'' and replaced it with the line ''port2 = port''. Running ''./python Lib/test/test_socket.py'' now yields: testGetServBy (__main__.GeneralModuleTests) ... ok . . . ---------------------------------------------------------------------- Ran 58 tests in 5.181s OK Located the code for ''socket_getservbyname'' in ''Modules/socketmodule.c'' where the call to the glibc function ''getservbyname'' is made: Py_BEGIN_ALLOW_THREADS sp = getservbyname(name, proto); Py_END_ALLOW_THREADS if (sp == NULL) { PyErr_SetString(socket_error, "service/proto not found"); return NULL; } The only call of socket.getservbyname 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_ParseTuple(args, "s|s:getservbyname", &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 嗨Steve, 这里是 socketmodule.c的编译行的缩减版,其中包含''socket_getservbyname'' 代码: gcc -pthread -DNDEBUG ... -c /usr/src/Python-2.4/Modules/socketmodule.c -o build / temp。 linux-i686-2.4 / socketmodule.o ''-pthread''我需要的线程类型? 我''我仍然好奇为什么只有一个参数的调用才能失败,而另外两个调用 传递两个参数不会失败。 有什么想法吗? pete jordan x2164 at mailcity com b $ b - ............ hi Steve, Here''s a cut down version of the compilation line forsocketmodule.c which contains the ''socket_getservbyname''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.getservbyname'' fails while the two other callswhich pass two arguments don''t fail. Any ideas?pete jordanx2164 atmailcity com --............ x2 *** @ mailcity.com 写道:大家好, Linux 2.4.28 Glibc 2.2.5 gcc 2.95.3 我是Python的新手。 我是'我从tar文件编译了Python 2.4。 运行''make test''我在test_socket中失败了。 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. 两个问题。首先,当您在 交互式提示符下运行时,以下代码会给出什么?: Py>进口插座 Py> socket.getservbyname(''daytime'') 13 其次,/ etc / services中是否有白天条目? 干杯, 尼克。 - Nick Coghlan | nc******@email.com |澳大利亚布里斯班 --------------------------------------- ------------------------ http://boredomandlaziness.skystorm.net Two questions. First, what does the following code give when you run it at theinteractive prompt?: Py> import socketPy> socket.getservbyname(''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 这篇关于test_socket.py失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 23:03