[Python-checkins] r84508 - in python/branches/release27-maint: Lib/test/test_fileio.py Misc/NEWS PC/msvcrtmodule.c

antoine.pitrou python-checkins at python.org
Sat Sep 4 23:24:42 CEST 2010


Author: antoine.pitrou
Date: Sat Sep 4 23:24:42 2010
New Revision: 84508
Log:
Merged revisions 84506 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
 r84506 | antoine.pitrou | 2010年09月04日 22:53:29 +0200 (sam., 04 sept. 2010) | 5 lines
 
 Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
 descriptor is provided. Patch by Pascal Chambon.
........
Modified:
 python/branches/release27-maint/ (props changed)
 python/branches/release27-maint/Lib/test/test_fileio.py
 python/branches/release27-maint/Misc/NEWS
 python/branches/release27-maint/PC/msvcrtmodule.c
Modified: python/branches/release27-maint/Lib/test/test_fileio.py
==============================================================================
--- python/branches/release27-maint/Lib/test/test_fileio.py	(original)
+++ python/branches/release27-maint/Lib/test/test_fileio.py	Sat Sep 4 23:24:42 2010
@@ -312,6 +312,9 @@
 def testInvalidFd(self):
 self.assertRaises(ValueError, _FileIO, -10)
 self.assertRaises(OSError, _FileIO, make_bad_fd())
+ if sys.platform == 'win32':
+ import msvcrt
+ self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd())
 
 def testBadModeArgument(self):
 # verify that we get a sensible error message for bad mode argument
Modified: python/branches/release27-maint/Misc/NEWS
==============================================================================
--- python/branches/release27-maint/Misc/NEWS	(original)
+++ python/branches/release27-maint/Misc/NEWS	Sat Sep 4 23:24:42 2010
@@ -228,6 +228,9 @@
 Extension Modules
 -----------------
 
+- Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
+ descriptor is provided. Patch by Pascal Chambon.
+
 - Issue #7736: Release the GIL around calls to opendir() and closedir()
 in the posix module. Patch by Marcin Bachry.
 
Modified: python/branches/release27-maint/PC/msvcrtmodule.c
==============================================================================
--- python/branches/release27-maint/PC/msvcrtmodule.c	(original)
+++ python/branches/release27-maint/PC/msvcrtmodule.c	Sat Sep 4 23:24:42 2010
@@ -141,6 +141,9 @@
 if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd))
 return NULL;
 
+ if (!_PyVerify_fd(fd))
+ return PyErr_SetFromErrno(PyExc_IOError);
+
 handle = _get_osfhandle(fd);
 if (handle == -1)
 return PyErr_SetFromErrno(PyExc_IOError);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /