[gdal-dev] testsuite question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] testsuite question

Ben Elliston
Hi Even

The testsuite has numerous instances like this:

    if version_info >= (3, 0, 0):
        for i in range(100000):
            exec("f.write(b'\\xa0\\x86\\x01\\x00\\x00\\x00\\x00\\x00')")
    else:
        for i in range(100000):
            f.write('\xa0\x86\x01\x00\x00\x00\x00\x00')

Why is it necessary on Python 3 to use exec() in this way?  It seems
very complicated and counterintuitive.

Thanks, Ben
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: testsuite question

Even Rouault-2

On lundi 23 avril 2018 11:54:25 CEST Ben Elliston wrote:

> Hi Even

>

> The testsuite has numerous instances like this:

>

> if version_info >= (3, 0, 0):

> for i in range(100000):

> exec("f.write(b'\\xa0\\x86\\x01\\x00\\x00\\x00\\x00\\x00')")

> else:

> for i in range(100000):

> f.write('\xa0\x86\x01\x00\x00\x00\x00\x00')

>

> Why is it necessary on Python 3 to use exec() in this way? It seems

> very complicated and counterintuitive.

 

Probably a remain of an era where we tried to be compatible of python 2.5. I see python >= 2.6 supports b'foo' so we could probably only use the b'' syntax whereever python3 needs it

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev