Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

UnicodeEncodeError: 'ascii' codec can't encode character for some files

2014-03-26
2014-04-04
  • I'm not able to upload files with unusual characters, like "ö". The filename containing this letter triggered the error below.

    I'm using s3cmd-1.0.1-1.el6.noarch on CentOS 6.3 - please advise.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
    Please report the following lines to:
    s3tools-bugs@lists.sourceforge.net
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Problem: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 52: ordinal not in range(128)
    S3cmd: 1.0.1

    Traceback (most recent call last):
    File "/usr/bin/s3cmd", line 2006, in <module>
    main()
    File "/usr/bin/s3cmd", line 1950, in main
    cmd_func(args)
    File "/usr/bin/s3cmd", line 330, in cmd_object_put
    destination_base = str(destination_base_uri)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 52: ordinal not in range(128)

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
    Please report the above lines to:
    s3tools-bugs@lists.sourceforge.net
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

     
  • I've updated to 1.5.0-beta1, and it's giving me a similar error:

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
    Please try reproducing the error using
    the latest s3cmd code from the git master
    branch found at:
    https://github.com/s3tools/s3cmd
    If the error persists, please report the
    following lines (removing any private
    info as necessary) to:
    s3tools-bugs@lists.sourceforge.net

    You have encountered a UnicodeEncodeError. Your environment
    variable LANG=en_US.UTF-8 may not specify a Unicode encoding (e.g. UTF-8).
    Please set LANG=en_US.UTF-8 or similar in your environment before
    invoking s3cmd.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Traceback (most recent call last):
    File "/usr/bin/s3cmd", line 2463, in <module>
    report_exception(e, msg)
    File "/usr/bin/s3cmd", line 2366, in report_exception
    sys.stderr.write("""Invoked as: %s""" % s)
    File "/usr/lib64/python2.6/codecs.py", line 351, in write
    data, consumed = self.encode(object, self.errors)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 75: ordinal not in range(128)

     
  • Any ideas? My LANG variable is already set to en_US.UTF-8:

    $ echo $LANG
    en_US.UTF-8

     
  • FYI, this one works:

    s3cmd put "dsdöasd" s3://tomasz.test

    And this one doesn't:

    s3cmd put "dsdöasd" "s3://tomasz.test/dsdöasd"

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
    Please try reproducing the error using
    the latest s3cmd code from the git master
    branch found at:
    https://github.com/s3tools/s3cmd
    If the error persists, please report the
    following lines (removing any private
    info as necessary) to:
    s3tools-bugs@lists.sourceforge.net

    You have encountered a UnicodeEncodeError. Your environment
    variable LANG=en_US.UTF-8 may not specify a Unicode encoding (e.g. UTF-8).
    Please set LANG=en_US.UTF-8 or similar in your environment before
    invoking s3cmd.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Traceback (most recent call last):
    File "/usr/bin/s3cmd", line 2463, in <module>
    report_exception(e, msg)
    File "/usr/bin/s3cmd", line 2366, in report_exception
    sys.stderr.write("""Invoked as: %s""" % s)
    File "/usr/lib64/python2.6/codecs.py", line 351, in write
    data, consumed = self.encode(object, self.errors)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 34: ordinal not in range(128)

     
  • Matt Domsch
    Matt Domsch
    2014-04-04

    For the record, I have fixed this now in upstream github.com/s3tools/s3cmd master branch.