rlib/test/test_rsocket.py::test_sethostname
@pytest.mark.skipif(sys.platform == "win32",
reason='No sethostname on Windows')
@pytest.mark.skipif(not hasattr(os, 'geteuid') or os.geteuid() == 0,
reason='Running as superuser is not supported.')
def test_sethostname():
# just in case it worked anyway, use the old hostname
> s = gethostname()
rlib/test/test_rsocket.py:774:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rlib/rsocket.py:1575: in gethostname
res = _c.gethostname(buf, size)
rtyper/lltypesystem/rffi.py:321: in wrapper
res = call_external_function(*real_args)
<46-codegen /workspace/rpython/rtyper/lltypesystem/rffi.py:217>:13: in call_external_function
res = funcptr(a0, a1)
rtyper/lltypesystem/lltype.py:1384: in __call__
return callb(*args)
rtyper/lltypesystem/ll2ctypes.py:1342: in __call__
return self.trampoline(*argvalues)
rtyper/lltypesystem/ll2ctypes.py:1374: in invoke_via_ctypes
cres = callme(cargs)
rtyper/lltypesystem/ll2ctypes.py:1360: in callme
return cfunc(*cargs)
/opt/pypy2.7-v7.3.22-linux64/lib_pypy/_ctypes/function.py:354: in __call__
self._convert_args(argtypes, args, kwargs))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ctypes._FuncPtr object at 0x000000002646b7f0>
argtypes = [<class '_ctypes.pointer.LP_ctypes_Array of Char {'nolength': True} *0'>, <class 'ctypes.c_int'>]
args = (<_ctypes.pointer.LP_ctypes_Array of Char {'nolength': True} *0 object at 0x0000000034838e18>, 1024L)
kwargs = {}, marker = <object object at 0x00000000226f3430>
def _convert_args(self, argtypes, args, kwargs, marker=object()):
newargs = []
outargs = []
keepalives = []
newargtypes = []
total = len(args)
paramflags = self._paramflags
if not paramflags and total < len(argtypes):
raise TypeError("not enough arguments")
if paramflags:
errcheckargs = []
inargs_idx = 0
for i, argtype in enumerate(argtypes):
flag = 0
defval = marker
paramflag = paramflags[i]
paramlen = len(paramflag)
name = None
if paramlen == 1:
flag = paramflag[0]
elif paramlen == 2:
flag, name = paramflag
elif paramlen == 3:
flag, name, defval = paramflag
flag = flag & PARAMFLAG_COMBINED
if flag == PARAMFLAG_FIN | PARAMFLAG_FLCID:
val = defval
if val is marker:
val = 0
errcheckargs.append(val)
keepalive, newarg, newargtype = self._conv_param(argtype, val)
keepalives.append(keepalive)
newargs.append(newarg)
newargtypes.append(newargtype)
elif flag in (0, PARAMFLAG_FIN):
if inargs_idx < total:
val = args[inargs_idx]
inargs_idx += 1
elif kwargs and name in kwargs:
val = kwargs[name]
inargs_idx += 1
elif defval is not marker:
val = defval
elif name:
raise TypeError("required argument '%s' missing" % name)
else:
raise TypeError("not enough arguments")
errcheckargs.append(val)
keepalive, newarg, newargtype = self._conv_param(argtype, val)
keepalives.append(keepalive)
newargs.append(newarg)
newargtypes.append(newargtype)
elif flag == PARAMFLAG_FOUT:
if defval is not marker:
val = defval
keepalive, newarg, newargtype = self._conv_param(argtype, defval)
else:
import ctypes
val = argtype._type_._newowninstance_()
keepalive = None
newarg = ctypes.byref(val)
newargtype = type(newarg)
errcheckargs.append(val)
outargs.append(val)
keepalives.append(keepalive)
newargs.append(newarg)
newargtypes.append(newargtype)
else:
raise ValueError("paramflag %d not yet implemented" % flag)
else:
errcheckargs = args
for i, argtype in enumerate(argtypes):
try:
keepalive, newarg, newargtype = self._conv_param(argtype, args[i])
except (UnicodeError, TypeError, ValueError) as e:
> raise ArgumentError(str(e))
E ArgumentError: expected LP_ctypes_Array of Char {'nolength': True} *0 instance instead of LP_ctypes_Array of Char {'nolength': True} *0
/opt/pypy2.7-v7.3.22-linux64/lib_pypy/_ctypes/function.py:589: ArgumentError
builder: rpython-linux-x86-64 build #716*
test: rlib/test/test_rsocket.py::test_sethostname