Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing null from Python strings #282

Merged
merged 1 commit into from
Dec 12, 2022
Merged

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.

None yet

2 participants