473,499 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.path.expanduser on Windows: UnicodeEncodeError

My application is getting this error on Windows XP (works fine on Mac OS X)
when it calls os.path.expanduser:
UnicodeEncodeError: 'ascii' codec can't encode characters in position
52-56: ordinal not in range(128)

The code was built with Python 2.3.4.

I found referenes to Path 957650, but I'm not familiar with how such fixes
are processed. Is there a patch I can add to fix this? How do I know what
version of Python it is fixed in - that is, will upgrading to Python 2.3.5
fix this?

Thanks for your help,

Bob Swerdlow
VP Engineering
Goombah - Music Discovery
rs*******@goombah.com
Jul 21 '05 #1
1 2464
Bob Swerdlow wrote:
My application is getting this error on Windows XP (works fine on Mac OS
X) when it calls os.path.expanduser:
UnicodeEncodeError: 'ascii' codec can't encode characters in position
52-56: ordinal not in range(128)
What does your environment look like? You can find out by typing
"SET" at a command prompt. The settings used are HOME, HOMEPATH and
HOMEDRIVE. Also helpful to print out the value being handed to
os.path.expanduser.
I found referenes to Path 957650, but I'm not familiar with how such
fixes are processed. Is there a patch I can add to fix this? How do I
know what version of Python it is fixed in - that is, will upgrading to
Python 2.3.5 fix this?


The patch is still "Status: Open" so hasn't been applied to a
release. It is not certain that this will fix your problem. The main
benefit of the patch appears to be IMO that it will use the standard
USERPROFILE environment variable.

Neil
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1944
by: Marco Aschwanden | last post by:
I want to store a file in the application directory. What is the easiest way to figure out, where my application is situated? sys.argv does not work for my purposes... do you have any other...
9
2423
by: Amir Dekel | last post by:
Hi everyone, I have two problems: 1. How can I keep my changes in sys.path after closing the interpreter? 2. os.path.expanduser("~") always gives me "C:\\" instead of my homepath. I have...
6
1827
by: kimes | last post by:
I've just started digging into how python works.. I found that other mudules are clearly declared like one file per a module.. But the only os.path doesn't have their own file.. ye I know is...
2
23359
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
8
2257
by: Tony Nelson | last post by:
On *nix, ~/foo refers to a file in a user's home directory. On MSWindows, users normally look at "My Documents" in their home directory. ISTM that a file that my program would put in ~/. on Linux...
2
2051
by: Kevin F | last post by:
where is this code looking for the .imap file? I am on OSX and am not sure where to put the file it is looking for. f = open(os.path.expanduser('~/.imap'))
0
969
by: Kevin F | last post by:
I have a code that opens an .imap file in os.path.expanduser. Unfortunately, I am on OS X and have no idea where that directory is. I am wondering how I can change this code to just open the...
1
5852
by: Peter Bienstman | last post by:
Hi, I'm trying to add support for unicode file names to my application. I'm running into problems with e.g. the os.path.exists routine, which complains if it gets passed a unicode string: ...
6
3390
by: lampshade | last post by:
Hello, I'm having some problems with os.path.isdir I think it is something simple that I'm overlooking. #!/usr/bin/python import os my_path = os.path.expanduser("~/pictures/") print...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.