Skip to content

gh-152150: Replacing the old getopt with argparse in base64#152152

Open
ByteFlowing1337 wants to merge 4 commits into
python:mainfrom
ByteFlowing1337:fix-152150
Open

gh-152150: Replacing the old getopt with argparse in base64#152152
ByteFlowing1337 wants to merge 4 commits into
python:mainfrom
ByteFlowing1337:fix-152150

Conversation

@ByteFlowing1337

@ByteFlowing1337 ByteFlowing1337 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there any real reason to do so? Are there any real bugs in using getopt? Will the performance change in a positive way? Will it break something?

@ByteFlowing1337

ByteFlowing1337 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

It is similar to what was done in #109164. I don't think it will break anything though, as the behavior remains the same?

  1. This change allows base64 to support long options like --help and --decode, which is more user-friendly and standard for CLIs (e.g. base64 in Linux supports both -d and --decode).
  2. It makes the usage message more helpful with colors and better formatting. It might be slightly slower than using getopt, but the trade-off is acceptable IMO.
  3. Maybe there aren't any bugs now in using getopt, but I think modernizing it to use argparse will make the code more readable and easier to maintain in the future.

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please, test new arguments in CLI tests :)

After I would defer this PR to someone else, because I am not a module expert :(

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants