s3tools / s3cmd

Official s3cmd repo -- Command line tool for managing S3 compatible storage services (including Amazon S3 and CloudFront).

Home Page:https://s3tools.org/s3cmd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

S3CMD --configure throws error

usagar80 opened this issue · comments

In mac, after installing latest s3cmd when I try to run configure command, it throws below error

ERROR: Test failed: sequence item 1: expected str instance, bytes found

image

Additionally I run --debug and saw the AWS send correct respond with info in XML format.

image

I'm getting something similar. This is from a brew install of v2.3.0

Invoked as: /opt/homebrew/bin/s3cmd ls
Problem: <class 'TypeError: sequence item 1: expected str instance, bytes found
S3cmd:   2.3.0
python:   3.12.0 (main, Oct  2 2023, 12:03:24) [Clang 15.0.0 (clang-1500.0.40.1)]
environment LANG=en_AU.UTF-8

Traceback (most recent call last):
  File "/opt/homebrew/bin/s3cmd", line 3286, in <module>
    rc = main()
         ^^^^^^
  File "/opt/homebrew/bin/s3cmd", line 3183, in main
    rc = cmd_func(args)
         ^^^^^^^^^^^^^^
  File "/opt/homebrew/bin/s3cmd", line 171, in cmd_ls
    subcmd_all_buckets_list(s3)
  File "/opt/homebrew/bin/s3cmd", line 176, in subcmd_all_buckets_list
    response = s3.list_all_buckets()
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/S3/S3.py", line 327, in list_all_buckets
    response["list"] = getListFromXml(response["data"], "Bucket")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/S3/BaseUtils.py", line 277, in getListFromXml
    tree = getTreeFromXml(xml)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/S3/BaseUtils.py", line 263, in getTreeFromXml
    xml, xmlns = stripNameSpace(encode_to_s3(xml))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/S3/BaseUtils.py", line 255, in stripNameSpace
    xml = RE_XML_NAMESPACE.sub("\\1\\2", xml, 1)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sequence item 1: expected str instance, bytes found

Any updates here? Facing the same issue

File "/opt/homebrew/lib/python3.12/site-packages/S3/BaseUtils.py", line 255, in stripNameSpace

    xml = RE_XML_NAMESPACE.sub("\\1\\2", xml, 1)

change to

    xml = RE_XML_NAMESPACE.sub(b"\\1\\2", xml, 1)

until a new release is made to work with Python 3.12. I think! Worked for me.

File "/opt/homebrew/lib/python3.12/site-packages/S3/BaseUtils.py", line 255, in stripNameSpace

    xml = RE_XML_NAMESPACE.sub("\\1\\2", xml, 1)

change to

    xml = RE_XML_NAMESPACE.sub(b"\\1\\2", xml, 1)

until a new release is made to work with Python 3.12. I think! Worked for me.

Ok, this worked for me, thanks for the help bud, appreciated 👍

This PR fixes this issue on Python 3.12 with s3cmd installed via brew.
#1355

This issue was already fixed in MASTER and there is now also a new release available with this correction: v2.4.0.