Message81459
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
therefore
* 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
error."
* "[EBADF] The fildes argument is not a valid file descriptor open
for
* 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
behaviour
* 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
studio
* 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);
#else
#define _PyVerify_fd(A) (1) /* dummy */
#endif |
|
Date |
User |
Action |
Args |
2009-02-09 15:17:29 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson, loewis, mhammond, amaury.forgeotdarc, ocean-city |
2009-02-09 15:17:29 | kristjan.jonsson | set | messageid: <1234192649.17.0.219403790184.issue4804@psf.upfronthosting.co.za> |
2009-02-09 15:17:27 | kristjan.jonsson | link | issue4804 messages |
2009-02-09 15:17:26 | kristjan.jonsson | create | |
|