Output Name Error on _axclrt.py#36
Merged
BUG1989 merged 1 commit intoAXERA-TECH:mainfrom Mar 19, 2025
Merged
Conversation
After investigating the issue, I found that the current code directly assigns the C pointer returned from the AxcrustEngineGetOutputNameByIndex function to the name variable. This causes Python to display the raw C pointer address (e.g., <cdata 'char *' 0x8820f70>) instead of the actual string value.
The proper solution involves a two-step process:
First, store the C pointer in a variable named cffi_name
Then, convert the C pointer to a string using axclrt_cffi.string() and decode it as a UTF-8 string with decode("utf-8")
This modification ensures that C string pointers are properly converted to Python strings, allowing the correct names to appear in the output results. This approach is consistent with the method already used in the _get_inputs() method.
Before change:
axengine/_axclrt.py LineNo.279
name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index)
After change:
axengine/_axclrt.py LineNo.279
cffi_name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index)
name = axclrt_cffi.string(cffi_name).decode("utf-8")
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.
#35
Current code assigns C pointers directly to name, displaying addresses instead of values. Solution: Store pointer in cffi_name, then convert using axclrt_cffi.string().decode("utf-8"). This properly converts C strings to Python strings, matching the approach in _get_inputs().
Before change:
axengine/_axclrt.py LineNo.279
name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index) After change:
axengine/_axclrt.py LineNo.279
cffi_name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index) name = axclrt_cffi.string(cffi_name).decode("utf-8")