summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-04-03 23:01:24 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-04-03 23:01:24 (GMT)
commit5fe715f049fa58166a07c677a9c68804a91392eb (patch)
treefbb8b5464093d464565a111315b99e6565644026 /Modules/posixmodule.c
parent9388020b86cbc21901f6cf4612866aaa9c85efbe (diff)
downloadcpython-5fe715f049fa58166a07c677a9c68804a91392eb.zip
cpython-5fe715f049fa58166a07c677a9c68804a91392eb.tar.gz
cpython-5fe715f049fa58166a07c677a9c68804a91392eb.tar.bz2
Properly support empty woperation in win32_startfile;
correct arguments to ShellExecuteW.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index db6f673..84e4637 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7469,28 +7469,31 @@ win32_startfile(PyObject *self, PyObject *args)
HINSTANCE rc;
#ifdef Py_WIN_WIDE_FILENAMES
if (unicode_file_names()) {
- PyObject *unipath, *woperation;
+ PyObject *unipath, *woperation = NULL;
if (!PyArg_ParseTuple(args, "U|s:startfile",
&unipath, &operation)) {
PyErr_Clear();
goto normal;
}
- woperation = PyUnicode_DecodeASCII(operation,
- strlen(operation), NULL);
- if (!woperation) {
- PyErr_Clear();
- goto normal;
+
+ if (operation) {
+ woperation = PyUnicode_DecodeASCII(operation,
+ strlen(operation), NULL);
+ if (!woperation) {
+ PyErr_Clear();
+ operation = NULL;
+ goto normal;
+ }
}
Py_BEGIN_ALLOW_THREADS
- rc = ShellExecuteW((HWND)0, operation,
+ rc = ShellExecuteW((HWND)0, woperation ? PyUnicode_AS_UNICODE(woperation) : 0,
PyUnicode_AS_UNICODE(unipath),
- PyUnicode_AS_UNICODE(woperation),
NULL, NULL, SW_SHOWNORMAL);
Py_END_ALLOW_THREADS
- Py_DECREF(woperation);
+ Py_XDECREF(woperation);
if (rc <= (HINSTANCE)32) {
PyObject *errval = win32_error_unicode("startfile",
PyUnicode_AS_UNICODE(unipath));