Issue 1007046: os.startfile() doesn't accept Unicode filenames (original) (raw)

WinXP, Python 2.3.4

os.startfile() seems to have problems with Unicode filenames. Example:

import tkFileDialog import os f = tkFileDialog.askopenfilename() type(f) <type 'unicode'> os.startfile(f)

Traceback (most recent call last): File "<pyshell#10>", line 1, in -toplevel- os.startfile(f) UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-16: ordinal not in range(128)

Logged In: YES user_id=38388

The path looks OK, but I can't test it on Windows (os.startfile() is only available on Windows).

A note on style: you should always try to keep lines shorter than 80 characters, e.g.:

--- CVS-Python/Modules/posixmodule.c 2005-08-15 10:15:27.000000000 +0200 +++ Dev-Python/Modules/posixmodule.c 2005-09-01 10:23:06.555633134 +0200 @@ -7248,7 +7248,8 @@ { char *filepath; HINSTANCE rc;

&filepath)) return NULL; Py_BEGIN_ALLOW_THREADS rc = ShellExecute((HWND)0, NULL, filepath, NULL, NULL, SW_SHOWNORMAL);