Armin Rigo <[EMAIL PROTECTED]> added the comment: Alternatively, we can try to make ctypes "feel like" C itself:
ctypes.set_errno(0) while True: dirent = linux_c_lib.readdir(byref(dir)) if not dirent: if ctypes.get_errno() == 0: break else: raise IOError("oups!") We are doing this kind of thing in PyPy with the "rffi" foreign function interface. To achieve this result, ctypes would have to maintain internally an internal, global (but thread-local) variable representing the current errno value. Just before doing a C library function call, ctypes would copy this variable into the real C-level errno; and immediately after the call it would read the C-level errno back into its internal variable. In this way, other calls to C functions unrelated to ctypes don't interfere. The get_errno() and set_errno() functions merely access the thread-local variable (not the real C-level errno). ---------- nosy: +arigo __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1798> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com