[ python-Bugs-1007046 ] os.startfile() doesn't accept Unicode filenames
SourceForge.net
noreply at sourceforge.net
Wed Sep 14 22:52:09 CEST 2005
Bugs item #1007046, was opened at 2004-08-11 08:47
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1007046&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Matthias Huening (huening)
>Assigned to: Reinhold Birkenfeld (birkenfeld)
Summary: os.startfile() doesn't accept Unicode filenames
Initial Comment:
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)
>>>
----------------------------------------------------------------------
>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-09-14 22:52
Message:
Logged In: YES
user_id=1188172
Checked this in now. posixmodule.c r2.340, r2.329.2.4.
----------------------------------------------------------------------
Comment By: M.-A. Lemburg (lemburg)
Date: 2005-09-01 10:27
Message:
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;
- if (!PyArg_ParseTuple(args, "s:startfile", &filepath))
+ if (!PyArg_ParseTuple(args, "et:startfile",
+ Py_FileSystemDefaultEncoding,
&filepath))
return NULL;
Py_BEGIN_ALLOW_THREADS
rc = ShellExecute((HWND)0, NULL, filepath, NULL,
NULL, SW_SHOWNORMAL);
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2005-08-24 07:18
Message:
Logged In: YES
user_id=80475
I'm unicode illiterate. Passing to MAL for review.
----------------------------------------------------------------------
Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-26 23:24
Message:
Logged In: YES
user_id=1188172
Attaching a patch which should fix that.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1007046&group_id=5470
More information about the Python-bugs-list
mailing list