Skip to content

Remove trailing null from Python strings#282

Merged
jmr merged 1 commit intogoogle:masterfrom
MikePlayle:remove-null
Dec 12, 2022
Merged

Remove trailing null from Python strings#282
jmr merged 1 commit intogoogle:masterfrom
MikePlayle:remove-null

Conversation

@MikePlayle
Copy link
Contributor

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'

@jmr
Copy link
Member

jmr commented Nov 28, 2022

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'
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.

2 participants