Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Exception while using annotation hashid

オープン
#230 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python

調査の方向性

cyclonedds/idl/_main.py のレポートに示されている md5 式から始め、annotate.member_hash_id を使って PersonHashid を定義し、その Topic を初期化して失敗を再現します。文字列アノテーションに対する hash-id の処理を確認し、Topic の初期化が TypeError なしで完了することを検証します。

索引モデルが issue の本文から書いたものです。

説明

When I use hash annotations to modify the dataclass field, I throw an exception: TypeError: Strings must be encoded before hashing
My dataclass is:
@dataclass
class PersonHashid(idl.IdlStruct, typename="PersonHashid"):
name: str
annotate.member_hash_id("name", "123")
age: types.int32
address: str

An exception occurred when I used the following code to initialize the topic :
participant = DomainParticipant(0)
topic = Topic(participant,"HelloWorldTopic", PersonHashid)

Abnormal information:
mid = unpack("<I", md5(f_annot.get("hash_id", "") or name.encode()).digest()[:4])[0] & 0x0FFFFFFF
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Strings must be encoded before hashing

After tracking the code, it was found that the problem occurred in the file cyclonedds/idl/_main. py: mid=unpack ("<I", md5 (f-annot. get ("hash_id", "") or name. encode()). digest() [: 4]) [0]&0x0FFFFFFF

Is the correct code supposed to be: mid=unpack ("<I", md5 ((f-annot. get ("hash_id", "") or name). encode()). digest() [: 4]) [0]&0x0FFFFFFF ?

主要言語
Python
スター
110
フォーク
68
平均マージ
3日 5時間
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

eclipse-cyclonedds/cyclonedds-python のほかの issue

eclipse-cyclonedds/cyclonedds-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。