FG
💻 Software☁️ Cloud & DevOpsAmazon

s3 sync/ls issues UnicodeWarning in Windows environment

Fresh5 days ago
Mar 14, 20260 views
Confidence Score55%
55%

Problem

What steps will reproduce the problem? 1. Log in to Windows(default language is non English(confirmed on Japanese)) 2. Run `aws s3 ls s3:://bucketname/ What is the expected output? What do you see instead? You will encounter `UnicodeWarning` as follows; [code block] What version of the product are you using? [code block] Additional information below. This is not a bug of aws-cli per se and is already reported to python-dateutils. https://bugs.launchpad.net/dateutil/+bug/1227221 But you encounter this warning every time you issue s3 commands, so it's a bit annoying.(`awscli` users are not always (Python) developers, right?) Working around this warning would be appreciated. (When releasing `awscli`, suppressing warning with `python -W ignore::UnicodeWarning` is one option) FYI, this warning also appears in #95(Which occurred in `argparse` module)

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Suppress UnicodeWarning in AWS CLI on Windows

Medium Risk

The UnicodeWarning occurs due to the handling of non-ASCII characters in the Windows environment, particularly when the default language is set to Japanese. This is related to how Python's dateutil library processes Unicode strings, leading to warnings when executing AWS CLI commands that involve S3 operations.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Create a Wrapper Script

    Create a wrapper script that suppresses the UnicodeWarning by setting the appropriate Python warning filters before executing the AWS CLI command.

    python
    #!/usr/bin/env python
    import warnings
    warnings.filterwarnings('ignore', category=UnicodeWarning)
    import subprocess
    import sys
    subprocess.call(['aws'] + sys.argv[1:])
  2. 2

    Save the Wrapper Script

    Save the above script as 'aws_s3_wrapper.py' in a directory included in your system's PATH, or specify the full path when executing.

  3. 3

    Use the Wrapper Script for AWS CLI Commands

    Instead of calling 'aws s3 ls', use the wrapper script by executing 'python aws_s3_wrapper.py s3 ls s3://bucketname'. This will run the AWS CLI commands without showing the UnicodeWarning.

    bash
    python aws_s3_wrapper.py s3 ls s3://bucketname
  4. 4

    Test the Implementation

    Run the wrapper script with various AWS CLI commands to ensure that the UnicodeWarning is suppressed and that the commands execute successfully.

    bash
    python aws_s3_wrapper.py s3 ls s3://bucketname

Validation

Confirm that executing the AWS CLI commands via the wrapper script does not produce any UnicodeWarning messages. If warnings are suppressed and commands execute as expected, the fix is successful.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

awscliclouds3syncfeature-requests3windows