summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2006-06-12 15:45:12 (GMT)
committerKristján Valur Jónsson <kristjan@ccpgames.com>2006-06-12 15:45:12 (GMT)
commitf608317061cc11de915f55da8c59880dc02e6d94 (patch)
treef018e0f56ed59b1fd2eb80f7bf5f9c0075712bdf /Objects/fileobject.c
parent81f444bb8eca9caedc884caf566c76233762077e (diff)
downloadcpython-f608317061cc11de915f55da8c59880dc02e6d94.zip
cpython-f608317061cc11de915f55da8c59880dc02e6d94.tar.gz
cpython-f608317061cc11de915f55da8c59880dc02e6d94.tar.bz2
Fix the CRT argument error handling for VisualStudio .NET 2005. Install a CRT error handler and disable the assertion for debug builds. This causes CRT to set errno to EINVAL.
This update fixes crash cases in the test suite where the default CRT error handler would cause process exit.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 2b37e74..050146a 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -241,13 +241,15 @@ open_the_file(PyFileObject *f, char *name, char *mode)
}
if (f->f_fp == NULL) {
-#ifdef _MSC_VER
+#if defined _MSC_VER && _MSC_VER < 1400
/* MSVC 6 (Microsoft) leaves errno at 0 for bad mode strings,
* across all Windows flavors. When it sets EINVAL varies
* across Windows flavors, the exact conditions aren't
* documented, and the answer lies in the OS's implementation
* of Win32's CreateFile function (whose source is secret).
* Seems the best we can do is map EINVAL to ENOENT.
+ * Starting with Visual Studio .NET 2005, EINVAL is correctly
+ * set by our CRT error handler (set in exceptions.c.)
*/
if (errno == 0) /* bad mode string */
errno = EINVAL;