GoogleCloudPlatform / GoogleCloudPlatform/gsutil

Encountered an error on Python 3.9 - AttributeError: module 'base64' has no attribute 'decodestring'

Open
#1,118 9 comments 10 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
918
Forks
335
PR merge metrics
No merged PRs in 30d

Description

Microsoft's app center has recently updated to Python 3.9, and I encountered the follow error when running gsutil on it:

```
Traceback (most recent call last):
File "/usr/local/bin/gsutil", line 5, in
from gslib.__main__ import main
File "/usr/local/lib/python3.9/site-packages/gslib/__main__.py", line 92, in
from gslib.command_runner import CommandRunner
File "/usr/local/lib/python3.9/site-packages/gslib/command_runner.py", line 64, in
from gslib.tests.util import HAS_NON_DEFAULT_GS_HOST
File "/usr/local/lib/python3.9/site-packages/gslib/tests/util.py", line 126, in
TEST_ENCRYPTION_KEY1_SHA256_B64 = Base64Sha256FromBase64EncryptionKey(
File "/usr/local/lib/python3.9/site-packages/gslib/utils/encryption_helper.py", line 152, in Base64Sha256FromBase64EncryptionKey
decoded_bytes = base64.decodestring(csek_encryption_key)
AttributeError: module 'base64' has no attribute 'decodestring'
```

This error is triggered with `gsutil -o Credentials:gs_service_key_file=./mykey.json cp src_url dist_url` command.

Any thoughts on how to get this command work on Python 3.9? Thank you.

Contributor guide

Open the contributing guide

Research direction

Start in gslib/utils/encryption_helper.py at Base64Sha256FromBase64EncryptionKey, where the Python 3.9 traceback points to the failing call. Reproduce the issue with the reported gsutil command under Python 3.9 and verify that it completes without the AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.