🌐 AI搜索 & 代理 主页
Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Handle readline stopiteration
  • Loading branch information
ShaharNaveh committed Nov 8, 2025
commit 30f54f6910fd7f21b0ff3877f3ac81ef7c0c8f4d
1 change: 0 additions & 1 deletion Lib/test/test_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def check_tokenize(self, s, expected):
[" ENCODING 'utf-8' (0, 0) (0, 0)"] +
expected.rstrip().splitlines())

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_invalid_readline(self):
def gen():
yield "sdfosdg"
Expand Down
9 changes: 7 additions & 2 deletions stdlib/src/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod _tokenize {
use crate::{
common::lock::PyRwLock,
vm::{
Py, PyPayload, PyResult, VirtualMachine,
AsObject, Py, PyPayload, PyResult, VirtualMachine,
builtins::{PyBytes, PyStr, PyStrRef, PyTypeRef},
convert::ToPyObject,
function::ArgCallable,
Expand Down Expand Up @@ -38,7 +38,12 @@ mod _tokenize {
// we need to check if it's callable and raise a type error if it's not.
let raw_line = match self.readline.invoke((), vm) {
Ok(v) => v,
Err(_) => return Ok(String::new()),
Err(err) => {
if err.fast_isinstance(vm.ctx.exceptions.stop_iteration) {
return Ok(String::new());
}
return Err(err);
}
};
Ok(match &self.encoding {
Some(encoding) => {
Expand Down
Loading