Skip to content

Problem: AttributeError: ConfigParser instance has no attribute 'read_string' #989

@mtmiller

Description

@mtmiller

Since version 2.0.2, s3cmd with Python 2.7 fails with this error, when using what comments in the code now refer to as the "deprecated credentials file format".

Invoked as: /tmp/s3cmd/bin/s3cmd ls s3://bucket/
Problem: AttributeError: ConfigParser instance has no attribute 'read_string'
S3cmd:   2.0.2
python:   2.7.15 (default, May  1 2018, 05:55:50) 
[GCC 7.3.0]
environment LANG=en_US.UTF-8

Traceback (most recent call last):
  File "/tmp/s3cmd/bin/s3cmd", line 3092, in <module>
    rc = main()
  File "/tmp/s3cmd/bin/s3cmd", line 2792, in main
    cfg = Config(options.config, options.access_key, options.secret_key, options.access_token)
  File "/tmp/s3cmd/local/lib/python2.7/site-packages/S3/Config.py", line 221, in __init__
    self.aws_credential_file()
  File "/tmp/s3cmd/local/lib/python2.7/site-packages/S3/Config.py", line 303, in aws_credential_file
    config.read_string(config_string.decode('utf-8'))
AttributeError: ConfigParser instance has no attribute 'read_string'

The contents of the credentials file are just the following two lines

aws_access_key_id=xxxx
aws_secret_access_key=yyyy

Any one of the following workarounds fixes this bug:

  1. Add a [default] header to the credentials file.
  2. pip install configparser to install the Python 3 compatible version of configparser.
  3. Downgrade to s3cmd 2.0.1, where this all worked previously.

This regression was introduced with the changes in PR #966.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions