Skip to content

Conversation

@bentyeh
Copy link

@bentyeh bentyeh commented Nov 8, 2025

Context

If a user calls set_tag(tag, value, value_type) where value_type='B', then the following error is raised:

ValueError('unsupported value_type {} in set_option'.format(typecode))

This corresponds to issue #1108.


Bug

Line 2512 of libcalignedsegment.pyx in the set_tag() function calls get_tag_typecode(value, value_type).

In its current implementation, get_tag_typecode will always return a value of 0 (indicating an unknown type) if value_type is 'B' due to 'B' missing from the enumerated types:

if value_type in 'aAsSIcCZidfH':
typecode = force_bytes(value_type)[0]

Back in set_tag(), this typecode value of 0 triggers the ValueError.


Solution

Add 'B' to the enumerated types in get_tag_typecode().

# Context

If a user calls `set_tag(tag, value, value_type)` where `value_type='B'`, then the following error is raised:

```
ValueError('unsupported value_type {} in set_option'.format(typecode))
```

---------------

# Bug

Line 2512 of libcalignedsegment.pyx in the `set_tag()` function calls `get_tag_typecode(value, value_type)`.

In its current implementation, `get_tag_typecode` will always return a value of 0 (indicating an unknown type) if `value_type` is `'B'` due to `'B'` missing from the enumerated types in line 244:

```
if value_type in 'aAsSIcCZidfH':
    typecode = force_bytes(value_type)[0]
```

Back in `set_tag()`, this typecode value of 0 triggers the ValueError.

-------------------

# Solution

Add `'B'` to the enumerated types in `get_tag_typecode()`.
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