os.stat UnicodeEncodeError:

Discussion in 'Python' started by Sandy Oz, Mar 22, 2011.

  1. Sandy Oz

    Sandy Oz Guest

    Hello everyone,


    I'm running into a problem with file names containing
    Unicode chars.

    Here is the error that I get when calling os.path.isfile:

    File "/usr/lib/python2.6/genericpath.py", line 29, in isfile
    st = os.stat(path)
    UnicodeEncodeError: 'ascii' codec can't encode characters in
    position 38-41: ordinal not in range(128)


    I'm working with python2.6, Ubuntu 10.10 running Gnome.

    The interesting thing is that I do not get this error when
    running the command in the python interpreter (with the same
    filename).

    Only when I do it through the application I developed.
    Shouldn't os module not be using the system locale in both
    cases?

    I tried setting the locale to en_US.UTF-8 but to no avail.


    Thank you,

    Sandy
     
    Sandy Oz, Mar 22, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton
    Replies:
    3
    Views:
    9,736
    Pete Becker
    Jun 2, 2005
  2. Patrick Useldinger

    os.stat('<filename>')[stat.ST_INO] on Windows

    Patrick Useldinger, Feb 27, 2005, in forum: Python
    Replies:
    6
    Views:
    1,197
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Mar 3, 2005
  3. Magesh
    Replies:
    3
    Views:
    453
    Gordon Burditt
    Oct 5, 2007
  4. Rolf Krüger
    Replies:
    2
    Views:
    630
    Ian Collins
    Mar 12, 2008
  5. ruck
    Replies:
    10
    Views:
    1,287
Loading...

Share This Page