Decode bytes to strings in Python Object API#8551
Conversation
|
Bump |
|
@aardappel bump, can we get the CI run on this PR? |
|
You can get the CI to run by rebasing, it is out of date.. I guess I'll do that for you. |
| return | ||
| self.name = nestedUnionTest.Name() | ||
| if self.name is not None: | ||
| self.name = self.name.decode('utf-8') |
There was a problem hiding this comment.
Is this meant to be self.name = nestedUnionTest.name.decode('utf-8') ?
There was a problem hiding this comment.
nestedUnionTest is not an object API type, so the only way to access the name from that object is via nestedUnionTest.Name().
This change is intentional, but if you're asking for a modification to the auto-generated code, I could change the autogeneration here to be
code += GetIndents(3) + "self." + field_field + " = " + struct_var + "." + field_method + "().decode('utf-8')";Then this would read
self.name = nestedUnionTest.Name()
if self.name is not None:
self.name = nestedUnionTest.Name().decode('utf-8')It's functionally the same, though, since self.name is set to nestedUnionTest.name() a couple lines beforehand. I personally think the current implementation is a bit more readable, but I'm open to suggestions.
|
Looks ok, I guess? @dbaileychess |
|
Bump @aardappel and @dbaileychess |
|
@aardappel, I see there's been some movement with other PRs - can this get merged? Thanks! |
|
Ok, lets merge, thanks! |
Type-hints for the Python Object API are incorrect for strings - the
_UnPack()method does not convert bytes to strings. This PR introduces an optional flag (false by default) that enables decoding the bytes into string objects.Resolves #5997