[vtk-developers] Minimum Python requirement

David Gobbi david.gobbi at gmail.com
Sat Feb 15 11:22:07 EST 2014


On Fri, Feb 14, 2014 at 11:27 PM, Andrew Maclean
<andrew.amaclean at gmail.com> wrote:
>
> From what I can see of newer Pythons the interpreter will not even look at
> the else section of the above code.

I'm going to nitpick here, because your statement here is not accurate.
Python looks at all of the code, in fact it has to in order to byte-compile the
code.  Take this code for instance:

import sys
if sys.hexversion >= 0x2060000:
    with open("test.txt") as f:
        print f.read()
else:
    print "unsupported keyword 'with'"

This code tries to check for python >= 2.6 before using the "with" keyword.
But if the code is run on python 2.5 it generates a syntax error regardless
of the check.

Python has nothing equivalent to "#if" or "#ifdef".

  David


>> ---------- Forwarded message ----------
>> From: David Gobbi <david.gobbi at gmail.com>
>> To: Ben Boeckel <ben.boeckel at kitware.com>
>> Cc: VTK Developers <vtk-developers at vtk.org>
>> Date: Thu, 13 Feb 2014 11:42:22 -0700
>> Subject: Re: [vtk-developers] Minimum Python requirement
>> For me, the dashboard should only show green if the test ran _and_
>> gave a valid result.
>>
>> I  know that many of the current tests show green if the machine is
>> incapable of producing a valid result (especially the ones that
>> require specific GPU functionality), but that's because there isn't an
>> easy way to check for the needed functionality until run time.
>>
>> On Thu, Feb 13, 2014 at 11:22 AM, Ben Boeckel <ben.boeckel at kitware.com>
>> wrote:
>> > On Thu, Feb 13, 2014 at 10:55:10 -0700, David Gobbi wrote:
>> >> Actually, the check should probably be done in the CMakeLists.txt:
>> >>
>> >> if(${PYTHON_VERSION} VERSION_GREATER "2.6")
>> >>   vtk_add_test_python(TestImageJSONWriter.py NO_VALID)
>> >> endif()
>> >
>> > I don't see why. We can certainly *run* the test on older Python
>> > versions, we just can't *validate* the test. In the absence of the
>> > latter, I'd take segfault discovery of a simple run test :) .
>> >
>> > --Ben



More information about the vtk-developers mailing list