This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2013-06-18 22:25 by David.Edelsohn, last changed 2022-04-11 14:57 by admin. 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);
     if (!PyArg_ParseTuple(args, "S:sethostname", &hnobj)) {
         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) (Python triager) 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

New changeset 14748397fc57 by Christian Heimes in branch 'default':
Issue #18259: Declare sethostname in socketmodule.c for AIX
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
Date User Action Args
2022-04-11 14:57:47adminsetgithub: 62459
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