if you can print out values of 'filemask', and 'thefile' variables, when it crashes, I can help.
thx. Edwin
-----Original Message-----
From: python-list-bounces+edwin.m adari=verizonwi reless.com@pyth on.org
[mailto:python-list-bounces+edwin.m adari=verizonwi reless.com@pyth on.org]
On Behalf Of Jorgen Bodde
Sent: Monday, August 04, 2008 2:24 PM
To: python-list@python.org
Subject: UnicodeDecodeEr ror, how to elegantly deal with this?
Hi All,
I am relatively new to python unicode pains and I would like to have
some advice. I have this snippet of code:
def playFile(cmd, args):
argstr = list()
for arg in appcfg.options[appcfg.CFG_PLAY ER_ARGS].split():
thefile = args["file"]
filemask = u"%file%"
therep = arg.replace(fil emask, thefile) ##### error here
argstr.append(t herep)
argstr.insert(0 , appcfg.options[appcfg.CFG_PLAY ER_PATH])
try:
subprocess.Pope n( argstr )
except OSError:
cmd.html = "<h1>Can't play file</h1></br>" + args["file"]
return
cmd.redirect = _getBaseURL("se ries?cmd_get_se ries=%i" % args["id"])
cmd.html = ""
-------------------
It crashes on this:
20:03:49: File
"D:\backup\impo rtant\src\airs\ webserver\webdi spatch.py", line 117, in
playFile therep = arg.replace(fil emask, thefile)
20:03:49: UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xc2 in
position 93: ordinal not in range(128)
20:03:49: Unhandled Error: <type 'exceptions.Uni codeDecodeError '>:
'ascii' codec can't decode byte 0xc2 in position 93: ordinal not in
range(128)
It chokes on a ` character in a file name. I read this file from disk,
and I would like to play it. However in the replace action it cannot
translate this character. How can I transparently deal with this issue
because in my eyes it is simply replacing a string with a string, and
I do not want to be bothered with unicode problems. I am not sure in
which encoding it is in, but I am not experienced enough to see how I
can solve this
Can anybody guide me to an elegant solution?
Thanks in advance!
- Jorgen
--
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
thx. Edwin
-----Original Message-----
From: python-list-bounces+edwin.m adari=verizonwi reless.com@pyth on.org
[mailto:python-list-bounces+edwin.m adari=verizonwi reless.com@pyth on.org]
On Behalf Of Jorgen Bodde
Sent: Monday, August 04, 2008 2:24 PM
To: python-list@python.org
Subject: UnicodeDecodeEr ror, how to elegantly deal with this?
Hi All,
I am relatively new to python unicode pains and I would like to have
some advice. I have this snippet of code:
def playFile(cmd, args):
argstr = list()
for arg in appcfg.options[appcfg.CFG_PLAY ER_ARGS].split():
thefile = args["file"]
filemask = u"%file%"
therep = arg.replace(fil emask, thefile) ##### error here
argstr.append(t herep)
argstr.insert(0 , appcfg.options[appcfg.CFG_PLAY ER_PATH])
try:
subprocess.Pope n( argstr )
except OSError:
cmd.html = "<h1>Can't play file</h1></br>" + args["file"]
return
cmd.redirect = _getBaseURL("se ries?cmd_get_se ries=%i" % args["id"])
cmd.html = ""
-------------------
It crashes on this:
20:03:49: File
"D:\backup\impo rtant\src\airs\ webserver\webdi spatch.py", line 117, in
playFile therep = arg.replace(fil emask, thefile)
20:03:49: UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xc2 in
position 93: ordinal not in range(128)
20:03:49: Unhandled Error: <type 'exceptions.Uni codeDecodeError '>:
'ascii' codec can't decode byte 0xc2 in position 93: ordinal not in
range(128)
It chokes on a ` character in a file name. I read this file from disk,
and I would like to play it. However in the replace action it cannot
translate this character. How can I transparently deal with this issue
because in my eyes it is simply replacing a string with a string, and
I do not want to be bothered with unicode problems. I am not sure in
which encoding it is in, but I am not experienced enough to see how I
can solve this
Can anybody guide me to an elegant solution?
Thanks in advance!
- Jorgen
--
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.