SQW: string lengths are written in characters but the strings in UTF-8 bytes
まだ誰も着手していません。
評価
調査の方向性
Issue では、SQW のシリアライズコードにある _ir._serialize_field、_write_single_struct、LowLevelSqw.write_char_array が挙げられています。まずこれらの実装と読み書きのヘルパーを読み、その後、Issue の再現手順と関連する SQW テストを実行してください。UTF-8 文字列が切り詰められずに往復し、次のフィールドの型タグが正しく読み取られれば完了です。
索引モデルが issue の本文から書いたものです。
説明
_ir._serialize_field declares an ir.String's length as len(field.value) (characters), while LowLevelSqw.write_chars writes value.encode("utf-8") (bytes). The reader reads that many bytes, so one non-ASCII character truncates the string and shifts every field after it.
import io
from scippneutron.io.sqw import _ir as ir
from scippneutron.io.sqw._bytes import Byteorder
from scippneutron.io.sqw._low_level_io import LowLevelSqw
from scippneutron.io.sqw._read_write import read_object_array, write_object_array
for text in ('malinger', 'målinger'):
buf = io.BytesIO()
w = LowLevelSqw(buf, path=None, byteorder=Byteorder.little)
write_object_array(w, ir._serialize_field(ir.String(text)))
w.write_u8(ir.TypeTag.f64.value) # next field's type tag
r = LowLevelSqw(io.BytesIO(buf.getvalue()), path=None, byteorder=Byteorder.little)
print(repr(read_object_array(r).data[0].value), r.read_u8())
# 'malinger' 3
# 'målinge' 114 <- truncated; 114 is ord('r'), read as the next type tag
In a real file, a run file path containing e.g. å makes experiment_info unreadable (ValueError: 101 is not a valid TypeTag). _write_single_struct has the same pattern, so far harmless because field names are ASCII. LowLevelSqw.write_char_array already uses the byte length.
Suggestion: len(field.value.encode("utf-8")) in both places.
Checked on scipp 26.11.0, scippneutron 26.10.0, essreduce 26.11.1, essspectroscopy 26.11.3.
- 主要言語
- Python
- スター
- 6
- フォーク
- 5
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
scipp/scippneutron のほかの issue
-
SQW: no reader for `f32`対応中かも @jl-wynen が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
scipp/scippneutron#756 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
scipp/scippneutron#752 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
scipp/scippneutron#750 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
scipp/scippneutron#749 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
scipp/scippneutron#755 ·
scipp/scippneutron の issue をすべて見る
似ている issue
-
Test: to_hijri() accepts datetime.datetime and uses only the date part対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンgood first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
omarelshamy25x/shamy-hijri#63 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
polish
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scores対応中かも @AshutoshSingh840 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
UKGovernmentBEIS/control-arena#992 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
mvalentsev/awesome-free-ai-coding#70 ·
メンテナーはふだん 1 日以内に返信