travis+ml-pyt...@subspacefield.org writes:

> On Mon, Jul 20, 2009 at 04:10:35PM +0200, Hrvoje Niksic wrote:
>> To emulate the os-module-type calls, it's better to raise exceptions
>> than return negative values:
>> 
>> > def setresuid(ruid, euid, suid):
>> >     return _setresuid(__uid_t(ruid), __uid_t(euid), __uid_t(suid))
>> 
>> def setresuid(ruid, euid, suid):
>>     res = _setresuid(__uid_t(ruid), __uid_t(euid), __uid_t(suid))
>>     if res < 0:
>>         raise OSError('[Errno %d] %s' % (os.errno, errno.strerror(os.errno)))
>
> I am working on a module to implement all of this, but that raise command
> won't work in Python 2.6.1; it turns out that os.errno is a module, not
> an integer.  Does anyone know how to do what I want (that is, how to access
> the errno set in C functions)?

You should use ctypes.get_errno() instead of os.errno; sorry about that.

Also, when raising OSError, you should set the 'errno' attribute to the
appropriate code.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to