[Python-checkins] r43586 - python/trunk/Modules/posixmodule.c (original) (raw)

Neal Norwitz nnorwitz at gmail.com
Tue Apr 4 06:57:44 CEST 2006


Unless I'm reading this patch wrong, it looks like it will crash if only a single parameter is passed in. With a single argument, operation is NULL and strlen(NULL) go boom.

I think this patch should be reverted, unless a test case is added and the coded corrected.

n

On 4/3/06, georg.brandl <python-checkins at python.org> wrote:

Author: georg.brandl Date: Mon Apr 3 14:26:26 2006 New Revision: 43586

Modified: python/trunk/Modules/posixmodule.c Log: Bug #1451503: allow unicode filenames in os.startfile().

Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Mon Apr 3 14:26:26 2006 @@ -7467,6 +7467,41 @@ char *filepath; char *operation = NULL; HINSTANCE rc; +#ifdef PyWINWIDEFILENAMES + if (unicodefilenames()) { + PyObject *unipath, *woperation; + if (!PyArgParseTuple(args, "U|s:startfile", + &unipath, &operation)) { + PyErrClear(); + goto normal; + } + + woperation = PyUnicodeDecodeASCII(operation, + strlen(operation), NULL); + if (!woperation) { + PyErrClear(); + goto normal; + } + + PyBEGINALLOWTHREADS + rc = ShellExecuteW((HWND)0, operation, + PyUnicodeASUNICODE(unipath), + PyUnicodeASUNICODE(woperation), + NULL, NULL, SWSHOWNORMAL); + PyENDALLOWTHREADS + + PyDECREF(woperation); + if (rc <= (HINSTANCE)32) { + PyObject *errval = win32errorunicode("startfile", + PyUnicodeASUNICODE(unipath)); + return errval; + } + PyINCREF(PyNone); + return PyNone; + } +#endif + +normal: if (!PyArgParseTuple(args, "et|s:startfile", PyFileSystemDefaultEncoding, &filepath, &operation))


Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins



More information about the Python-checkins mailing list