cli: avoid panic when -X int_max_str_digits has no value by cuishuang · Pull Request #8677 · RustPython/RustPython · GitHub
Skip to content

cli: avoid panic when -X int_max_str_digits has no value - #8677

Merged
youknowone merged 1 commit into
RustPython:mainfrom
cuishuang:main
Sep 10, 2026
Merged

cli: avoid panic when -X int_max_str_digits has no value#8677
youknowone merged 1 commit into
RustPython:mainfrom
cuishuang:main

Conversation

@cuishuang

@cuishuang cuishuang commented Sep 8, 2026

Copy link
Copy Markdown
Contributor
  • I did not use AI to write the code of this patch.
  • This PR follows our AI policy

Summary

Passing -X int_max_str_digits without a value unwraps None and causes a Rust panic before reaching the existing configuration error handler.

Handle the optional value before parsing so missing values report the existing invalid limit diagnostic and exit with status 1.

AI assistance: Codex (GPT-6) assisted with the regression test, validation, and I have reviewed and understand the code.

Summary by CodeRabbit

  • Bug Fixes

    • Invalid or missing -X int_max_str_digits values now produce a clear error instead of causing an interpreter panic.
    • Valid limits, including 640 and 0, continue to be accepted and reported correctly.
  • Tests

    • Added coverage for valid, invalid, and missing command-line option values.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2193a15c7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +5 to +9
for option in (
"int_max_str_digits",
"int_max_str_digits=639",
"int_max_str_digits=invalid",
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the newly added test logic

This new snippet introduces test assertions, control flow, and test data, but the repository rules state that test assertions, logic, and data must not be modified and limit acceptable test-file changes to adding or removing expected-failure markers. Remove this test-file addition and keep the behavioral fix confined to the Rust implementation.

AGENTS.md reference: AGENTS.md:L273-L279

Useful? React with 👍 / 👎.

@ShaharNaveh ShaharNaveh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tysm!

@codspeed-hq

codspeed-hq Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 12.48%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 65 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
gc_collect.py[rustpython] 206.6 ms 236.1 ms -12.48%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cuishuang:main (2193a15) with main (c6c1b1c)

Open in CodSpeed

@youknowone youknowone 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.

Thank you for contributing! Please check lint failuire

https://github.com/RustPython/RustPython/actions/runs/34241535912/job/102112661455?pr=8677
clicking prek run will show you what's failing.

Everything others looks great. Thanks!

Signed-off-by: cuishuang <imcusg@gmail.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@cuishuang

Copy link
Copy Markdown
Contributor Author

@youknowone youknowone 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.

👍

@youknowone
youknowone merged commit 8195385 into RustPython:main Sep 10, 2026
28 checks passed
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