Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Match CPython group id conversion and update grp tests - #9462

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowdot:py315-grp-gid-converter-20261029
Oct 30, 2026
Merged

youknowone merged 2 commits into
RustPython:mainfrom
youknowdot:py315-grp-gid-converter-20261029

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Match CPython's grp.getgrgid() conversion through __index__, including overflow versus missing-group errors, the -1 sentinel, and bounded type names in diagnostics.
  • Preserve CPython's signed long and unsigned long conversion paths rather than collapsing out-of-range gids into KeyError.
  • Migrate the whole Lib/test/test_grp.py using scripts/update_lib; the resulting file is byte-identical to pinned CPython and retires its sole expected-failure marker.

CPython basis

Pinned source: d220409a13b77de7a6c30abe16ea90db01528edc.

Validation

  • Scoped cargo check and strict Clippy passed with a dedicated worktree target and fresh stdlib artifacts.
  • CLI build passed; 16 finite invalid-gid cases on each engine produced identical full JSON results against the pinned CPython build. These cases include integer overflow, __index__ failures/non-integer results, and UTF-8-safe type-name truncation; none reaches an OS group database lookup.
  • Normal commit hooks passed, including rustfmt, cspell, Ruff and redundant-test-patch checks. Hook formatting after execution only reformatted the existing missing-group error closure.
  • Canonical test_grp was not run locally: it performs NSS/group-database queries. Actual test_grp execution on Unix CI is required before calling this integration validated. Windows lacks this Unix-only module; a skipped Windows module is not evidence of coverage.
  • Full workspace and C API test suites were not run locally. CI is pending.

The underlying host lookup/error handling is otherwise unchanged. This does not claim validation on exotic signed-gid_t targets.

Local checks used base f98543dcdbe49fc902c17f28f81cc980fa69dd3f. Latest main observed before publication was d24ca415d8ee8ac439e19ef50e624abb64c48482; intervening changes only touched JSON files, not this patch. Merge-result integration remains a CI responsibility, not a claimed local rebase test.

AI assistance: OpenAI Codex; model version unavailable. The commit includes the corresponding Assisted-by trailer.

Summary by CodeRabbit

  • Bug Fixes
    • Group lookup now reports invalid argument types as TypeError and out-of-range IDs as OverflowError, rather than treating these cases as missing groups.
    • Missing groups continue to raise KeyError, with the requested group ID included in the message.

Assisted-by: OpenAI Codex: model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d24ca41 and 29ced28.

Files ignored due to path filters: 1
  • Lib/test/test_grp.py is excluded by !Lib/**
Files selected for processing: 1
  • crates/stdlib/src/grp.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

grp.getgrgid now converts the original argument explicitly, applies signed-long and gid range checks, and reports conversion, range, and lookup failures with distinct exception types.

Changes: grp.getgrgid argument handling

Layer / File(s) Summary
Argument conversion and lookup
crates/stdlib/src/grp.rs
getgrgid preserves the original argument for integer conversion. It raises TypeError for conversion failures, accepts -1 as a sentinel, raises OverflowError for other invalid values, and raises KeyError when lookup fails.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • RustPython/RustPython#9242 — Its argument-binding changes affect how surplus positional arguments are handled before conversion, including calls to grp.getgrgid().

Suggested reviewers: youknowone, lsahn-gh

Merge Risk: Minimal · up to 29ced

No actionable merge-blocking issue remains. The argument conversion changes are mergeable subject to normal checks, including Unix group-database integration tests.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: matching CPython group ID conversion behavior and updating the associated tests.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] test: cpython/Lib/test/test_grp.py

dependencies:

dependent tests: (192 tests)

  • grp: test_pathlib test_shutil test_subprocess test_tarfile
    • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_httpservers test_importlib test_json test_launcher test_logging test_netrc test_os test_pathlib test_peg_generator test_pkgutil test_profiling test_pyrepl test_runpy test_tempfile test_tomllib test_tools test_traceback test_unparse test_venv test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd
      • compileall: test_compileall
      • importlib: test_asdl_parser test_bdb test_cmd_line_script test_codecs test_ctypes test_doctest test_external_inspection test_frozen test_hashlib test_importlib test_inspect test_interpreters test_linecache test_modulefinder test_multiprocessing_main_handling test_py_compile test_pyclbr test_pydoc test_pyrepl test_reprlib test_source_encoding test_sundry test_support test_unittest test_zipfile test_zipimport test_zoneinfo
      • profiling.sampling.heatmap_collector: test_profiling
      • traceback: test_asyncio test_builtin test_code_module test_concurrent_futures test_contextlib test_contextlib_async test_coroutines test_crossinterp test_dictcomps test_exceptions test_http_cookiejar test_iter test_listcomps test_pyexpat test_setcomps test_socket test_ssl test_sys test_threadedtempfile test_threading test_unittest test_with
      • zipapp: test_pdb
    • shutil: test_argparse test_bz2 test_ctypes test_embed test_filecmp test_glob test_io test_multiprocessing_forkserver test_os test_peepholer test_profiling test_sax test_site test_string_literals test_sysconfig test_unicode_file
      • ctypes.util: test_ctypes
      • http.server: test_robotparser test_urllib2_localnet test_xmlrpc
      • multiprocessing.util: test_asyncio test_concurrent_futures
      • tempfile: test_asyncio test_bytes test_cmd_line test_compile test_concurrent_futures test_csv test_curses test_dis test_dtrace test_faulthandler test_fileinput test_free_threading test_generated_cases test_genericalias test_importlib test_interpreters test_mailbox test_ntpath test_os test_pickle test_pickletools test_pkg test_profiling test_pstats test_pyrepl test_readline test_regrtest test_selectors test_shlex test_sys_settrace test_tabnanny test_termios test_tokenize test_turtle test_urllib test_urllib2 test_urllib_response test_wave test_winconsoleio test_zipfile64
      • webbrowser: test_webbrowser
    • subprocess: test_android test_asyncio test_atexit test_audit test_c_locale_coercion test_concurrent_futures test_file_eintr test_gc test_gzip test_msvcrt test_osx_env test_platform test_plistlib test_poll test_profiling test_pyrepl test_quopri test_remote_pdb test_repl test_script_helper test_select test_signal test_sqlite3 test_tcl test_tkinter test_tstring test_unittest test_utf8_mode test_wait3 test_xpickle
      • asyncio: test_asyncio
      • imaplib: test_imaplib
      • platform: test__locale test__osx_support test_baseexception test_calendar test_cmath test_fcntl test_math test_mimetypes test_startfile test_strptime test_time test_tkinter test_winreg test_wsgiref

[x] lib: cpython/Lib/json
[ ] test: cpython/Lib/test/test_json (TODO: 2)

dependencies:

  • json

dependent tests: (21 tests)

  • json: test_embed test_interpreters test_json test_logging test_plistlib test_profiling test_pydoc test_pyrepl test_remote_pdb test_subprocess test_sysconfig test_tomllib test_tools test_traceback test_zoneinfo
    • importlib.metadata: test_importlib
    • multiprocessing.resource_tracker: test_concurrent_futures
    • pdb: test_pdb
    • profiling: test_profiling
      • cProfile: test_free_threading test_pstats

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@codspeed

codspeed Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:py315-grp-gid-converter-20261029 (dbaeaac) with main (d24ca41)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread crates/stdlib/src/grp.rs
let index = id.id.try_index(vm).map_err(|_| {
let name = id.id.class().slot_name().to_string();
let name = &name[..name.floor_char_boundary(200.min(name.len()))];
vm.new_type_error(format!("gid should be integer, not {name}"))

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.

we must be able to override this using ArgIndex now. pls check other error messages if this is necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switched to the existing ArgIndex::try_from_object path in 29ced2896d, without adding a new converter API.

The call-site error override is still needed: CPython's _Py_Gid_Converter deliberately replaces every _PyNumber_Index failure, including exceptions raised by __index__, with TypeError("gid should be integer, not <type>"). The current #[pyarg(error_msg = ...)] supports only a fixed string, so it cannot preserve this type-dependent diagnostic. Both overflow messages and the normalized-gid KeyError were also checked against that implementation and remain unchanged.

Scoped Cargo check and strict Clippy passed, along with normal commit hooks. NSS was not invoked locally; the canonical test_grp coverage is left to the new-head CI.

Preserve CPython-specific gid index failure diagnostics through the existing argument converter.

Assisted-by: OpenAI Codex: model version unavailable
@youknowone
youknowone marked this pull request as ready for review October 30, 2026 17:54
@youknowone
youknowone enabled auto-merge (squash) October 30, 2026 17:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-30T17:56:07.407407Z
We couldn’t complete this review. Comment @codex review to try again.
29ced28 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@youknowone
youknowone merged commit 621be14 into RustPython:main Oct 30, 2026
29 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