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 kristjan.jonsson
Recipients amaury.forgeotdarc, kristjan.jonsson, loewis, mhammond, ocean-city
Date 2009-02-09.15:17:25
SpamBayes Score 4.7521262e-09
Marked as misclassified No
Message-id <>
Ok, how about this comment, Martin?

/* Microsoft CRT in VS2005 and higher will verify that a filehandle is
 * valid and throw an assertion if it isn't.
 * Normally, an invalid fd is likely to be a C program error and 
 * an assertion can be useful, but it does contradict the POSIX standard
 * which for write(2) states:
 *    "Otherwise, -1 shall be returned and errno set to indicate the 
 *    "[EBADF] The fildes argument is not a valid file descriptor open 
 *     writing."
 * Furthermore, python allows the user to enter any old integer
 * as a fd and should merely raise a python exception on error.
 * The Microsoft CRT doesn't provide an official way to check for the
 * validity of a file descriptor, but we can emulate its internal 
 * by using the exported __pinfo data member and knowledge of the 
 * internal structures involved.
 * The structures below must be updated for each version of visual 
 * according to the file internal.h in the CRT source, until MS comes
 * up with a less hacky way to do this.
 * (all of this is to avoid globally modifying the CRT behaviour using
 * _set_invalid_parameter_handler() and _CrtSetReportMode())

Also, I've added the following to fileobject.h, not coming up with a 
better place:

#if defined _MSC_VER && _MSC_VER >= 1400
/* A routine to check if a file descriptor is valid on Windows.  
Returns 0
 * and sets errno to EBADF if it isn't.  This is to avoid Assertions
 * from various functions in the Windows CRT beginning with
 * Visual Studio 2005
int _PyVerify_fd(int fd);
#define _PyVerify_fd(A) (1) /* dummy */
Date User Action Args
2009-02-09 15:17:29kristjan.jonssonsetrecipients: + kristjan.jonsson, loewis, mhammond, amaury.forgeotdarc, ocean-city
2009-02-09 15:17:29kristjan.jonssonsetmessageid: <>
2009-02-09 15:17:27kristjan.jonssonlinkissue4804 messages
2009-02-09 15:17:26kristjan.jonssoncreate