Skip to content

Conversation

@tonghuaroot
Copy link

@tonghuaroot tonghuaroot commented Jan 18, 2026

Description

Lib/test/test_decimal.py currently uses the deprecated optparse module for parsing command-line arguments. This task involves migrating it to use argparse.

Proposed Changes

  • Replace optparse imports with argparse.
  • Update argument parsing logic to use argparse.ArgumentParser.
  • Ensure all existing command-line options (--debug, --skip) are supported.
  • Fix any formatting issues (e.g. % in help strings).

Verification

  • Run python Lib/test/test_decimal.py --help
  • Run python Lib/test/test_decimal.py --skip

@bedevere-app
Copy link

bedevere-app bot commented Jan 18, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app bedevere-app bot added tests Tests in the Lib/test dir awaiting review labels Jan 18, 2026
@bedevere-app
Copy link

bedevere-app bot commented Jan 18, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

…mal.py

The optparse module is deprecated since Python 3.2. This change migrates
Lib/test/test_decimal.py to use the argparse module for command line
argument parsing.

This involves:
- Importing argparse instead of optparse.
- Using ArgumentParser instead of OptionParser.
- Updating argument definitions (add_argument).
- Escaping '%' characters in help strings.
- Updating execution logic to use the argparse Namespace object.
@tonghuaroot tonghuaroot changed the title Modernize Lib/test/test_decimal.py: use argparse instead of optparse gh-143984: Replace optparse with argparse in Lib/test/test_decimal.py Jan 18, 2026
@bedevere-app
Copy link

bedevere-app bot commented Jan 18, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant