Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/test/exception_hierarchy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ BaseException
├── ReferenceError
├── RuntimeError
│ ├── NotImplementedError
│ ├── PythonFinalizationError
│ └── RecursionError
├── StopAsyncIteration
├── StopIteration
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_builtin.py
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.

These changes are unrelated, but failed on my machine. I guess that they are skipped on thr CI

Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,7 @@ def detach_readline(self):
else:
yield

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
def test_input_tty(self):
# Test input() functionality when wired to a tty
self.check_input_tty("prompt", b"quux")
Expand All @@ -2710,17 +2711,20 @@ def test_input_tty_non_ascii_unicode_errors(self):
# Check stdin/stdout error handler is used when invoking PyOS_Readline()
self.check_input_tty("prompté", b"quux\xe9", "ascii")

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
def test_input_tty_null_in_prompt(self):
self.check_input_tty("prompt\0", b"",
expected='ValueError: input: prompt string cannot contain '
'null characters')

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
def test_input_tty_nonencodable_prompt(self):
self.check_input_tty("prompté", b"quux", "ascii", stdout_errors='strict',
expected="UnicodeEncodeError: 'ascii' codec can't encode "
"character '\\xe9' in position 6: ordinal not in "
"range(128)")

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
def test_input_tty_nondecodable_input(self):
self.check_input_tty("prompt", b"quux\xe9", "ascii", stdin_errors='strict',
expected="UnicodeDecodeError: 'ascii' codec can't decode "
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ def test_reverse_name_mapping(self):
module, name = mapping(module, name)
self.assertEqual((module, name), (module3, name3))

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_exceptions(self):
self.assertEqual(mapping('exceptions', 'StandardError'),
('builtins', 'Exception'))
Expand Down
1 change: 1 addition & 0 deletions crates/vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,7 @@ pub fn init_module(vm: &VirtualMachine, module: &Py<PyModule>) {
"TimeoutError" => ctx.exceptions.timeout_error.to_owned(),
"ReferenceError" => ctx.exceptions.reference_error.to_owned(),
"RuntimeError" => ctx.exceptions.runtime_error.to_owned(),
"PythonFinalizationError" => ctx.exceptions.python_finalization_error.to_owned(),
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Check if exception_hierarchy.txt exists and verify PythonFinalizationError placement
echo "=== Checking exception_hierarchy.txt ==="
fd -t f 'exception_hierarchy' --exec cat {}

# Verify python_finalization_error field exists in the exceptions context
echo -e "\n=== Verifying python_finalization_error field exists ==="
rg -n 'python_finalization_error' --type rust

# Check for any related tests or documentation
echo -e "\n=== Checking for related tests ==="
rg -n 'PythonFinalizationError' --type rust -g '!builtins.rs'

Repository: RustPython/RustPython

Length of output: 14832


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== exception_hierarchy* files ==="
fd -t f 'exception_hierarchy' .

echo
echo "=== exception_hierarchy* occurrences of PythonFinalizationError ==="
for f in $(fd -t f 'exception_hierarchy' .); do
  if rg -n 'PythonFinalizationError' "$f" >/dev/null; then
    echo "-- $f"
    rg -n 'PythonFinalizationError' "$f"
  fi
done

echo
echo "=== builtins.rs context around line 1477 ==="
nl -ba crates/vm/src/stdlib/builtins.rs | sed -n '1455,1505p'

echo
echo "=== builtins.rs comment about exception_hierarchy.txt ==="
nl -ba crates/vm/src/stdlib/builtins.rs | sed -n '1405,1445p'

echo
echo "=== exceptions.rs definition of PyPythonFinalizationError base ==="
nl -ba crates/vm/src/exceptions.rs | sed -n '2425,2475p'

Repository: RustPython/RustPython

Length of output: 1964


Confirm PythonFinalizationError wiring; hierarchy ordering can’t be checked from exception_hierarchy.txt

  • ctx.exceptions.python_finalization_error exists (crates/vm/src/exceptions.rs) and the builtins mapping follows the same pattern as other exceptions.
  • The exception_hierarchy/exception_hierarchy.txt content available here doesn’t include PythonFinalizationError, so the “ordered by exception_hierarchy.txt” requirement can’t be validated—add it to the hierarchy file (or adjust the ordering comment) to keep this guarantee accurate.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/vm/src/stdlib/builtins.rs` at line 1477, The builtins mapping adds
"PythonFinalizationError" pointing to ctx.exceptions.python_finalization_error
but the exception_hierarchy.txt doesn’t include that symbol so the “ordered by
exception_hierarchy.txt” guarantee is invalid; update exception_hierarchy.txt to
include PythonFinalizationError in the proper place in the hierarchy (or adjust
the ordering comment in crates/vm/src/stdlib/builtins.rs) and ensure the symbol
name matches the constructor defined in crates/vm/src/exceptions.rs
(PythonFinalizationError / ctx.exceptions.python_finalization_error) so the
wiring and ordering are consistent.

"NotImplementedError" => ctx.exceptions.not_implemented_error.to_owned(),
"RecursionError" => ctx.exceptions.recursion_error.to_owned(),
"SyntaxError" => ctx.exceptions.syntax_error.to_owned(),
Expand Down
Loading