Skip to content

Conversation

@adev-code
Copy link
Contributor

@adev-code adev-code commented Feb 2, 2026

Python 3.14 is more strict with how argparse handles % characters in help strings. While Python 3 has always treated % as format specifiers, Python 3.14 enforces this more strictly. When service model documentation contains % (e.g., IAM's UpdateAccountPasswordPolicy RequireSymbols parameter), argparse raises: ValueError: unsupported format character '^' (0x5e) at index 129

A similar fix was applied for CLIArgument in PR #9790. This commit adds the same .replace('%', '%%') escaping to BooleanArgument.add_to_parser() and adds tests to verify the CLI's argument classes properly handle % characters.

Fixes compatibility with Python 3.14+ for CLI v1.

Addresses:
#10038

Python 3.14+ argparse treats % characters in help strings as format specifiers. When service model documentation contains % (e.g., IAM's UpdateAccountPasswordPolicy RequireSymbols parameter), argparse raises: ValueError: unsupported format character '^' (0x5e) at index 129

This was already fixed for CLIArgument in PR aws#9790 but BooleanArgument was missed. This commit adds the same .replace('%', '%%') escaping to BooleanArgument.add_to_parser() and adds a test to verify all service operations with % in documentation work correctly.

Fixes compatibility with Python 3.14+
@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.39%. Comparing base (c4681b5) to head (c2f2d40).
⚠️ Report is 95 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #10044   +/-   ##
========================================
  Coverage    93.39%   93.39%           
========================================
  Files          210      210           
  Lines        17052    17069   +17     
========================================
+ Hits         15925    15941   +16     
- Misses        1127     1128    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace expensive test that iterated through all services with focused unit tests that directly verify % character escaping behavior. The new tests use controlled test data to verify both CLIArgument and BooleanArgument properly escape % in symbols (% ^) and URL-encoded strings (%28%29) when passed to argparse.
Copy link
Member

@kdaily kdaily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change is OK, and the testing idea for making sure strings with formatting-specific characters is appropriate. I left a comment about the specifics of how the test is implemented. Lets get that updated and this should be good to go.

@kdaily
Copy link
Member

kdaily commented Feb 3, 2026

Let's also update the description in this PR to clarify that the argparse module in Python 3.14 is more strict with how it handles % characters - Python 3 has always treated them as formatting related.

@kdaily
Copy link
Member

kdaily commented Feb 3, 2026

Can you also confirm that the HTML and man-page docs render as expected for boolean parameters?

@adev-code
Copy link
Contributor Author

Can you also confirm that the HTML and man-page docs render as expected for boolean parameters?

It renders as expected and only has one %, not %%

Screenshot 2026-02-03 at 11 36 34 AM Screenshot 2026-02-03 at 11 37 27 AM

Update tests to use AWS CLI's ArgTableArgParser instead of standard
argparse.ArgumentParser to properly test the CLI's argument parser
abstraction. Extract common test logic into helper method to reduce
code duplication.
@adev-code adev-code requested a review from kdaily February 3, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants