Skip to content

Fix to_bytes and to_str raising a string instead of an exception - #1220

Open
magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:fix/to-bytes-to-str-raise-string-not-exception
Open

magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:fix/to-bytes-to-str-raise-string-not-exception

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

Description

to_bytes and to_str did raise f'invalid data type {type(data)}', which raises a plain string instead of an exception. Python turns this into an unrelated TypeError: exceptions must derive from BaseException instead of the intended message. Fixed by wrapping the message in TypeError.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: N/A, self-discovered while reviewing this file, no existing issue filed.

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested review from a team as code owners September 18, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant