Skip to content

Conversation

@ShaharNaveh
Copy link
Collaborator

@ShaharNaveh ShaharNaveh commented Aug 17, 2025

Summary by CodeRabbit

  • New Features
    • The pyexpat module now exposes a version_info attribute returning the module version as a tuple (2, 7, 1), allowing scripts to detect pyexpat’s exact version at runtime for compatibility checks and conditional logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 17, 2025

Walkthrough

Replaces the module header block comment with a Rust doc comment and introduces a new Python-facing attribute by adding #[pyattr(name = "version_info")] pub const VERSION_INFO: (u32, u32, u32) = (2, 7, 1); inside #[pymodule(name = "pyexpat")] mod _pyexpat in stdlib/src/pyexpat.rs.

Changes

Cohort / File(s) Summary
pyexpat module updates
stdlib/src/pyexpat.rs
Converted header block comment to a Rust doc comment and added #[pyattr(name = "version_info")] pub const VERSION_INFO: (u32, u32, u32) = (2, 7, 1); at module scope within #[pymodule(name = "pyexpat")] mod _pyexpat.

Sequence Diagram(s)

sequenceDiagram
  participant Py as Python code
  participant Mod as _pyexpat module
  participant Const as VERSION_INFO

  Py->>Mod: access attribute `version_info`
  Mod->>Const: read constant (module-level)
  Const-->>Mod: (2, 7, 1)
  Mod-->>Py: return (2, 7, 1)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops in lines of byte,
Pins a tuple neat and bright.
(2, 7, 1) in plain sight,
Doc comment gleams, the module's right.
Carrot hops — code done, good night. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 76b65a2 and a4dbfa9.

📒 Files selected for processing (1)
  • stdlib/src/pyexpat.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • stdlib/src/pyexpat.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
stdlib/src/pyexpat.rs (2)

1-1: Use inner module doc comments (//!) at the crate/module root

At the top of a module/file, prefer //! so the doc attaches to the module itself rather than the next item.

-/// Pyexpat builtin module
+//! Pyexpat builtin module

42-49: Expose version tuple efficiently; drop PyInt dependency

Implementation is correct. You can simplify by using vm.ctx.new_int(...) to avoid importing PyInt and the extra into_pyobject conversions.

-    #[pyattr]
-    pub fn version_info(vm: &VirtualMachine) -> PyTupleRef {
-        vm.ctx.new_tuple(vec![
-            PyInt::from(2).into_pyobject(vm),
-            PyInt::from(7).into_pyobject(vm),
-            PyInt::from(1).into_pyobject(vm),
-        ])
-    }
+    #[pyattr]
+    pub fn version_info(vm: &VirtualMachine) -> PyTupleRef {
+        vm.ctx.new_tuple(vec![
+            vm.ctx.new_int(2).into(),
+            vm.ctx.new_int(7).into(),
+            vm.ctx.new_int(1).into(),
+        ])
+    }

If you adopt the above, you can also remove PyInt from the imports:

-        builtins::{PyInt, PyStr, PyStrRef, PyTupleRef, PyType},
+        builtins::{PyStr, PyStrRef, PyTupleRef, PyType},
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a9a9e3b and 8249938.

⛔ Files ignored due to path filters (13)
  • Lib/test/test_xml_dom_xmlbuilder.py is excluded by !Lib/**
  • Lib/test/test_xml_etree.py is excluded by !Lib/**
  • Lib/test/test_xml_etree_c.py is excluded by !Lib/**
  • Lib/xml/dom/expatbuilder.py is excluded by !Lib/**
  • Lib/xml/dom/minidom.py is excluded by !Lib/**
  • Lib/xml/dom/xmlbuilder.py is excluded by !Lib/**
  • Lib/xml/etree/ElementInclude.py is excluded by !Lib/**
  • Lib/xml/etree/ElementPath.py is excluded by !Lib/**
  • Lib/xml/etree/ElementTree.py is excluded by !Lib/**
  • Lib/xml/sax/__init__.py is excluded by !Lib/**
  • Lib/xml/sax/_exceptions.py is excluded by !Lib/**
  • Lib/xml/sax/expatreader.py is excluded by !Lib/**
  • Lib/xml/sax/xmlreader.py is excluded by !Lib/**
📒 Files selected for processing (1)
  • stdlib/src/pyexpat.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust

Files:

  • stdlib/src/pyexpat.rs
🧬 Code Graph Analysis (1)
stdlib/src/pyexpat.rs (2)
vm/src/builtins/str.rs (10)
  • from (126-128)
  • from (132-134)
  • from (138-140)
  • from (144-146)
  • from (150-152)
  • from (156-158)
  • from (162-164)
  • from (168-170)
  • from (174-176)
  • from (180-182)
vm/src/builtins/int.rs (1)
  • into_pyobject (56-58)
🔇 Additional comments (2)
stdlib/src/pyexpat.rs (2)

32-32: LGTM: Imports expanded appropriately for new attribute

Adding PyInt and PyTupleRef is correct for constructing the tuple in version_info. No issues spotted.


42-49: Confirm attribute naming parity with CPython’s pyexpat API

I ran a repo-wide search for any existing references to pyexpat.version_info, expat_version_info, expat_version, or EXPAT_VERSION and found none. Please verify that:

  • pyexpat.version_info is the intended public name for this 3.13.7 sync
  • No existing code/tests elsewhere depend on a different attribute name
  • If matching CPython’s API is required, consider exporting one or more of the following aliases for compatibility:
    • pyexpat.expat_version
    • pyexpat.expat_version_info
    • pyexpat.EXPAT_VERSION

Comment on lines 43 to 49
pub fn version_info(vm: &VirtualMachine) -> PyTupleRef {
vm.ctx.new_tuple(vec![
PyInt::from(2).into_pyobject(vm),
PyInt::from(7).into_pyobject(vm),
PyInt::from(1).into_pyobject(vm),
])
}
Copy link
Member

@youknowone youknowone Aug 20, 2025

Choose a reason for hiding this comment

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

Suggested change
pub fn version_info(vm: &VirtualMachine) -> PyTupleRef {
vm.ctx.new_tuple(vec![
PyInt::from(2).into_pyobject(vm),
PyInt::from(7).into_pyobject(vm),
PyInt::from(1).into_pyobject(vm),
])
}
pub fn version_info(_vm: &VirtualMachine) -> (u32, u32, u32) {
(2, 7, 1)
}

This may work

@ShaharNaveh ShaharNaveh requested a review from youknowone August 20, 2025 13:17
@youknowone youknowone merged commit 9417e10 into RustPython:main Aug 21, 2025
12 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.

2 participants