Skip to content

Match SymbolTable repr with CPython format#7139

Merged
youknowone merged 1 commit intoRustPython:mainfrom
moreal:fix/fail-symtable-test_symtable_entry_repr
Feb 14, 2026
Merged

Match SymbolTable repr with CPython format#7139
youknowone merged 1 commit intoRustPython:mainfrom
moreal:fix/fail-symtable-test_symtable_entry_repr

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Feb 14, 2026

Summary by CodeRabbit

  • Improvements
    • Symbol table objects now display with detailed information (table name, object ID, and line number) when printed in the Python REPL or error messages.
    • Updated symbol table class identifier for clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

The pull request modifies symtable.rs to add Python-level representation support for PySymbolTable. It imports Representable, changes the exported class name from "SymbolTable" to "symtable entry", decorates the class with with(Representable), and implements a custom repr_str method for formatted output.

Changes

Cohort / File(s) Summary
Symbol Table Representation
crates/vm/src/stdlib/symtable.rs
Added imports (Py, types::Representable), renamed pyclass from "SymbolTable" to "symtable entry", added with(Representable) to pyclass attribute, and implemented Representable trait with custom repr formatting including class name, table name, object id, and line number.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • RustPython/RustPython#6048: Modifies the same PySymbolTable type with API/property refactoring while this PR changes its representation and class naming.

Suggested reviewers

  • youknowone

Poem

🐰 A symbol table dressed in new attire,
With symtable entry and repr to inspire,
Hops through the code with representable flair,
Displaying its essence with formatting care! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (29 files):

⚔️ .github/workflows/upgrade-pylib.md (content)
⚔️ Cargo.lock (content)
⚔️ Lib/collections/__init__.py (content)
⚔️ Lib/hashlib.py (content)
⚔️ Lib/test/test_collections.py (content)
⚔️ Lib/test/test_hashlib.py (content)
⚔️ Lib/test/test_hmac.py (content)
⚔️ Lib/test/test_inspect/test_inspect.py (content)
⚔️ Lib/test/test_keywordonlyarg.py (content)
⚔️ Lib/test/test_positional_only_arg.py (content)
⚔️ Lib/test/test_re.py (content)
⚔️ Lib/test/test_smtplib.py (content)
⚔️ Lib/test/test_struct.py (content)
⚔️ Lib/test/test_symtable.py (content)
⚔️ Lib/test/test_ucn.py (content)
⚔️ Lib/test/test_unicodedata.py (content)
⚔️ Lib/test/test_urlparse.py (content)
⚔️ crates/codegen/src/compile.rs (content)
⚔️ crates/stdlib/Cargo.toml (content)
⚔️ crates/stdlib/src/blake2.rs (content)
⚔️ crates/stdlib/src/hashlib.rs (content)
⚔️ crates/stdlib/src/md5.rs (content)
⚔️ crates/stdlib/src/sha1.rs (content)
⚔️ crates/stdlib/src/sha256.rs (content)
⚔️ crates/stdlib/src/sha3.rs (content)
⚔️ crates/stdlib/src/sha512.rs (content)
⚔️ crates/stdlib/src/unicodedata.rs (content)
⚔️ crates/vm/src/stdlib/symtable.rs (content)
⚔️ crates/vm/src/vm/mod.rs (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Match SymbolTable repr with CPython format' accurately describes the main change, which is implementing a Representable trait for PySymbolTable to align its string representation with CPython's format.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/fail-symtable-test_symtable_entry_repr
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

@github-actions
Copy link
Contributor

📦 Library Dependencies

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

[ ] lib: cpython/Lib/hashlib.py
[ ] test: cpython/Lib/test/test_hashlib.py (TODO: 9)

dependencies:

  • hashlib

dependent tests: (15 tests)

  • hashlib: test_hashlib test_hmac test_smtplib test_tarfile test_unicodedata test_urllib2_localnet
    • urllib.request: test_http_cookiejar test_pathlib test_pydoc test_site test_ssl test_urllib test_urllib2 test_urllib2net test_urllibnet

[x] lib: cpython/Lib/symtable.py
[ ] test: cpython/Lib/test/test_symtable.py (TODO: 17)

dependencies:

  • symtable

dependent tests: (1 tests)

  • symtable: test_symtable

Legend:

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

@moreal moreal self-assigned this Feb 14, 2026

#[pyattr]
#[pyclass(name = "SymbolTable")]
#[pyclass(name = "symtable entry")]
Copy link
Member

Choose a reason for hiding this comment

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

SymbolTable itself is not an entry, is this correct?

@moreal moreal marked this pull request as ready for review February 14, 2026 13:51
@youknowone youknowone merged commit e8698aa into RustPython:main Feb 14, 2026
24 of 25 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