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.

Author arigo
Recipients amaury.forgeotdarc, arigo, fijal, theller
Date 2008-05-22.19:57:02
SpamBayes Score 0.046629142
Marked as misclassified No
Message-id <1211486224.45.0.854183029981.issue1798@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2008-05-22 19:57:04arigosetspambayes_score: 0.0466291 -> 0.046629142
recipients: + arigo, theller, amaury.forgeotdarc, fijal
2008-05-22 19:57:04arigosetspambayes_score: 0.0466291 -> 0.0466291
messageid: <1211486224.45.0.854183029981.issue1798@psf.upfronthosting.co.za>
2008-05-22 19:57:03arigolinkissue1798 messages
2008-05-22 19:57:02arigocreate