google / s2geometry

Computational geometry and spatial indexing on the sphere
http://s2geometry.io/
Apache License 2.0
2.29k stars 302 forks source link

Remove trailing null from Python strings #282

Closed MikePlayle closed 1 year ago

MikePlayle commented 1 year ago

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 commented 1 year ago

Could you add a test here? https://github.com/google/s2geometry/blob/master/src/python/pywraps2_test.py