Repository navigation
fix: compare attribute names as UTF-8 during attribute combination - #897
Merged
Merged
Conversation
szhorvat
commented
Nov 28, 2026
Member
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the non-ASCII attribute-name handling fix.
No open issues 🎉
What changed in this PR
This PR fixes non-ASCII attribute-name handling in the Python-to-C interface so attribute combination works in Graph.simplify() and Graph.contract_vertices().
Changes:
- Use UTF-8-aware comparisons when matching attribute records and combining attributes.
- Add regression coverage for non-ASCII edge and vertex attribute names.
- Document the fix in the changelog.
| File | Description |
|---|---|
tests/test_attributes.py |
Tests combining non-ASCII attributes during simplification and vertex contraction. |
src/_igraph/attributes.c |
Replaces two ASCII comparisons with UTF-8-aware comparisons. |
CHANGELOG.md |
Documents the non-ASCII attribute-combination fix. |
Review effort: Balanced
szhorvat
marked this pull request as draft
November 28, 2026 15:17
Attribute names are passed to the C core as UTF-8, but they were compared against the Python keys with PyUnicode_IsEqualToASCIIString(). For a non-ASCII name the comparison always failed, so Graph.simplify() and Graph.contract_vertices() raised an InternalError when combining attributes, and adding vertices or edges with attribute values from the C core could overwrite the existing values of such an attribute. Use igraphmodule_PyUnicode_IsEqualToUTF8String() instead, both in the combination loop and when matching attribute records. Since that helper allocates a temporary Python string, make it return -1 with a Python exception set on failure, and raise an igraph error in all callers instead of treating the failure as a mismatch. Assisted-by: Claude Opus 5.5
szhorvat
force-pushed
the
fix/utf8-attribute-names
branch
from
November 28, 2026 15:24
45aa681 to
f33e337
Compare
szhorvat
marked this pull request as ready for review
November 28, 2026 15:51
ntamas
approved these changes
Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.