-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent invalid utf8 indexing in cell magic detection (#9146)
The example below used to panic because we tried to split at 2 bytes in the 4-bytes character `转`. ```python def sample_func(xx): """ 转置 (transpose) """ return xx.T ``` Fixes #9145 Fixes astral-sh/ruff-vscode#362 The second commit is a small test refactoring.
- Loading branch information
Showing
3 changed files
with
72 additions
and
54 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
crates/ruff_notebook/resources/test/fixtures/jupyter/cell/unicode_magic_gh9145.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"execution_count": null, | ||
"cell_type": "code", | ||
"id": "1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def sample_func(xx):\n", | ||
" \"\"\"\n", | ||
" 转置 (transpose)\n", | ||
" \"\"\"\n", | ||
" return xx.T", | ||
"# https://github.com/astral-sh/ruff-vscode/issues/362", | ||
"DEFAULT_SYSTEM_PROMPT = (", | ||
" \"Ты — Сайга, русскоязычный автоматический ассистент. \"", | ||
" \"Ты разговариваешь с людьми и помогаешь им.\"", | ||
")" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters