[Scons-users] Problem upgrading from 3.0.1 to 3.1.2

Steve Hill (Wireless) Steve.Hill1 at viavisolutions.com
Sun May 17 04:12:13 EDT 2020


Thanks David. I think that splitdrive was modified to require a PathLike in Python 3.

I wonder whether CmdStringHolder should implement that interface? Also, rather than catching a TypeError (which is a pretty wide exception that could be thrown for a number of bugs), might it be better to determine whether it is callable()?

From: Daniel Moody <dmoody256 at gmail.com>
Sent: 15 May 2020 17:35
To: SCons users mailing list <scons-users at scons.org>
Cc: Steve Hill (Wireless) <Steve.Hill1 at viavisolutions.com>
Subject: Re: [Scons-users] Problem upgrading from 3.0.1 to 3.1.2

I was able to reproduce this with near latest scons and python3.6 with this simple SConstruct:

SConstruct:
import os

class TestPathIssue(object):

    def __init__(self, thing, makePathsRelative = True, debug = False):
        pass

    def __call__(self, target, source, env, for_signature):
        def FakeClass(object):
            pass
        # simulate the exception
        fake = FakeClass()
        os.path.splitdrive(fake)

env = Environment()
env["TESTCLASS"] = TestPathIssue
env["CCCOM"] = "$CC $_CCCOMCOM $CCFLAGS -o ${TESTCLASS('$TARGET')} -c ${TESTCLASS('$SOURCES')}"

env.Program(target='foo', source='foo.c')

foo.c:
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
        argv[argc++] = "--";
        printf("foo.c");
        exit (0);
}

resulted in:

python3.6 ../scons/scripts/scons.py --debug=stacktrace
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o <SCons.Script.TestPathIssue object at 0x7fa562bfada0> -c <SCons.Script.TestPathIssue object at 0x7fa562bfaa90>
sh: 1: Syntax error: end of file unexpected
scons: *** [foo.o] Error 2
my example also fails in python2.7 however, which indicates that there is something different in behavior with your call method between python2 and python3. But that's probably another issue in itself, there is still an issue here in my example where the exception silently passes through. I traced TypeErrors in Subst.py and found its failing into this incorrect assumption here: https://github.com/SCons/scons/blob/4795a9988303cabc0abf774f6f4f77bf2519a5f8/SCons/Subst.py#L429-L431<https://urldefense.com/v3/__https:/github.com/SCons/scons/blob/4795a9988303cabc0abf774f6f4f77bf2519a5f8/SCons/Subst.py*L429-L431__;Iw!!Aa6LgkyVeQ!9PJ3eFZ7lUL2PBV-1gse7fRbZSWJiReAZ0zr94Ftn3-gq0i_Y_z2k7zS2UdruuqhrT5uQ7yt$>

except TypeError:
# This probably indicates that it's a callable
# object that doesn't match our calling arguments
# (like an Action).
which is where the __call__ methods exception got ignored. If this comment is a correct assumption, then it should also be assumed that any __call__ method implemented by the user should be catching its own exceptions, and handling them or rethrowing them as a more specific exception.






On Fri, May 15, 2020 at 1:24 AM Steve Hill (Wireless) via Scons-users <scons-users at scons.org<mailto:scons-users at scons.org>> wrote:
>> I'm sort of gradually drifting over to msys2 instead as a result

Me too - haven't used Cygwin for years but this toolchain uses its own version...

Back on topic, is it by design that SCons will silently ignore an exception raised during execution of a callable in this scenario? I normally follow the 'fail quickly and fail loud' approach to this sort of unexpected behaviour...

S.

-----Original Message-----
From: Scons-users <scons-users-bounces at scons.org<mailto:scons-users-bounces at scons.org>> On Behalf Of Mats Wichmann
Sent: 14 May 2020 17:44
To: scons-users at scons.org<mailto:scons-users at scons.org>
Subject: Re: [Scons-users] Problem upgrading from 3.0.1 to 3.1.2

On 5/14/20 10:39 AM, Steve Hill (Wireless) via Scons-users wrote:
>>> who's calling os.path.splitdrive?  is that scons, or you?
>
> Me, in the Cygwinify class (as I have, in some - but not all - cases, to change C:\ to /cygdrive/c/ if it is an absolute path...). I really hate this particular toolchain.

Yeah... the git-for-windows stuff has proved nicer, and I'm sort of gradually drifting over to msys2 instead as a result - the special /cygdrive/ prefix has always been an irritant for me. Not that I'm not letting the discussion drift off-topic here  :)



===
> who's calling os.path.splitdrive?  is that scons, or you?
>
> as a Python library function, it won't know about SCons defined datatypes, though CmdStringHolder is just a specialization of collections.UserString...
>
_______________________________________________
Scons-users mailing list
Scons-users at scons.org<mailto:Scons-users at scons.org>
https://urldefense.com/v3/__https://pairlist4.pair.net/mailman/listinfo/scons-users__;!!Aa6LgkyVeQ!4XSRL_pTX7Ag1XqtIWZ7VKsvbRTB4dDZ2q-vSSPNyJVGMYNSlb3RajVKCTxqJTDT8GMSTqZs$<https://urldefense.com/v3/__https:/pairlist4.pair.net/mailman/listinfo/scons-users__;!!Aa6LgkyVeQ!4XSRL_pTX7Ag1XqtIWZ7VKsvbRTB4dDZ2q-vSSPNyJVGMYNSlb3RajVKCTxqJTDT8GMSTqZs$>
_______________________________________________
Scons-users mailing list
Scons-users at scons.org<mailto:Scons-users at scons.org>
https://pairlist4.pair.net/mailman/listinfo/scons-users<https://urldefense.com/v3/__https:/pairlist4.pair.net/mailman/listinfo/scons-users__;!!Aa6LgkyVeQ!9PJ3eFZ7lUL2PBV-1gse7fRbZSWJiReAZ0zr94Ftn3-gq0i_Y_z2k7zS2Udruuqhra5C0qe_$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20200517/e7f8d738/attachment-0001.html>


More information about the Scons-users mailing list