classification
Title: Declare sethostname in socketmodule.c for AIX
Type: compile error Stage: resolved
Components: Build Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David.Edelsohn, christian.heimes, haypo, python-dev
Priority: normal Keywords:

Created on 2013-06-18 22:25 by David.Edelsohn, last changed 2013-06-19 12:14 by berker.peksag. This issue is now closed.

Messages (3)
msg191439 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2013-06-18 22:25
AIX provides sethostname() but it is not declared in any useful header. Fixed as follows:

diff -r 626a8e49f2a9 Modules/socketmodule.c
--- a/Modules/socketmodule.c    Tue Jun 18 23:28:18 2013 +0200
+++ b/Modules/socketmodule.c    Tue Jun 18 20:17:37 2013 -0700
@@ -4066,6 +4066,10 @@
     Py_buffer buf;
     int res, flag = 0;
 
+#ifdef _AIX
+extern int sethostname(const char *, size_t);
+#endif
+
     if (!PyArg_ParseTuple(args, "S:sethostname", &hnobj)) {
         PyErr_Clear();
         if (!PyArg_ParseTuple(args, "O&:sethostname",

It seemed best to declare it inside the function. I placed it below the other declarations, not immediately before the function use.
msg191440 - (view) Author: Roundup Robot (python-dev) Date: 2013-06-19 00:09
New changeset 9f8efcd78d0d by Christian Heimes in branch '3.3':
Issue #18259: Declare sethostname in socketmodule.c for AIX
http://hg.python.org/cpython/rev/9f8efcd78d0d

New changeset 14748397fc57 by Christian Heimes in branch 'default':
Issue #18259: Declare sethostname in socketmodule.c for AIX
http://hg.python.org/cpython/rev/14748397fc57
msg191441 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-06-19 00:35
Seems to work. I don't have root permission on the box so I can't actually test if the function call succeeds.

% ./python 
Python 3.4.0a0 (default:626a8e49f2a9, Jun 19 2013, 00:19:57) 
[GCC 4.7.1] on aix7
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.sethostname('python')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
PermissionError: [Errno 1] Not owner
History
Date User Action Args
2013-06-19 12:14:13berker.peksagsetversions: - Python 3.5
2013-06-19 00:35:11christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg191441

resolution: fixed
stage: resolved
2013-06-19 00:09:10python-devsetnosy: + python-dev
messages: + msg191440
2013-06-18 22:25:52David.Edelsohncreate