[ python-Bugs-1681974 ] mkdtemp fails on Windows if username has non-ASCII character

SourceForge.net noreply at sourceforge.net
Fri Mar 16 11:03:49 CET 2007


Bugs item #1681974, was opened at 2007-03-16 12:03
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1681974&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: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Markus Niemistö (niemisto)
Assigned to: Nobody/Anonymous (nobody)
Summary: mkdtemp fails on Windows if username has non-ASCII character

Initial Comment:
mkdtemp fails miserably on Windows if Windows user name has any non-ASCII characters, like ä or ö, in it. mkdtemp throws an encoding error.

This seems to be because the default temp dir in Windows is "c:\documents and settings\<user name>\local settings\temp". Now if the user name has non-ASCII characters ASCII decoder cannot handle it and creating temp directories won't work.

As a work around I have used the following code:

tempdir = unicode(tempfile.gettempdir(), 'mbcs')
mkdtemp(suffix='foo', dir=tempdir)

This applies for both Python 2.4 and Python 2.5.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1681974&group_id=5470


More information about the Python-bugs-list mailing list