runtimeverification / runtimeverification/llvm-backend

pybind11 raises a `UnicodeDecodeError` on non-utf bytes in terms of sort `Bytes`

Open
#1,078 1 comment 0 reactions 1 assignee View on GitHub

@gtrepta is already working on this.

Since Jun 6, 2024.

bindings
Dominant language
C++
Stars
43
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Terms of sort Bytes and String are both stored in a kore_string_pattern in the AST library and treated the same way when being accessed from the bindings:

https://github.com/runtimeverification/llvm-backend/blob/2983a01dccf1d278aaea3c9c1d989c5273eaab55/bindings/python/ast.cpp#L360-L363

The issue here is when the contents property is accessed, pybind assumes it's a valid utf encoded string. This isn't always the case for Bytes terms, though, and an exception gets thrown in that case.

Pybind does support returning an unconverted string, so we should find out how to do that for terms that need to be treated that way.

https://pybind11.readthedocs.io/en/stable/advanced/cast/strings.html#returning-c-strings-to-python

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.