Remove trailing null from Python strings#282
Merged
jmr merged 1 commit intogoogle:masterfrom Dec 12, 2022
Merged
Conversation
Member
|
Could you add a test here? https://github.com/google/s2geometry/blob/master/src/python/pywraps2_test.py |
Python strings have an explicit length, not a terminating zero byte. Before: $ python Python 3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pywraps2 as s2 >>> str(s2.S1Angle.Degrees(123)) '123.0000000\x00' >>> str(s2.S2CellId(12345)) '0/000000000000000000000001200130\x00' After: $ python Python 3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pywraps2 as s2 >>> str(s2.S1Angle.Degrees(123)) '123.0000000' >>> str(s2.S2CellId(12345)) '0/000000000000000000000001200130'
7631587 to
c9392c6
Compare
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.
Python strings have an explicit length, not a terminating zero byte.
Before:
$ python
Python 3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.
After:
$ python
Python 3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.