[Scons-users] TryRun() problem with python3 scons-3.0.1

Dave Plater dplater.list at gmail.com
Thu Mar 8 08:59:35 EST 2018


Hi, I'm battling to find why these SConstruct sections fails with 
"TypeError : sequence item 0: expected str instance, bytes found"

def CompilerCheck( context ):
     context.Message( "Checking for a working C-compiler " )
     ret = context.TryRun( """
#include <stdio.h>

int main() {
     printf( "Hello World!" );
     return 0;
}""", '.c' ).decode('utf-8')[0]
     context.Result( ret )

or

     if 'CFLAGS' in env:
         oldcf = env['CFLAGS']
     else:
         oldcf = ""
     env.Append(CFLAGS = '-std=c99')
     if conf.CheckLibWithHeader( "m", "math.h", "c", "lrint(3.2);"
).decode('utf-8'):
         HAVE_LRINT = 1
     else:
         HAVE_LRINT = 0
     if conf.CheckLibWithHeader( "m", "math.h", "c", "lrintf(3.2);"
).decode('utf-8'):
         HAVE_LRINTF = 1
     else:
         HAVE_LRINTF = 0
     env['HAVE_LRINT'] = HAVE_LRINT;
     env['HAVE_LRINTF'] = HAVE_LRINTF;
     env.Replace(CFLAGS=oldcf)

What am I doing wrong? I've tried suffixing .decode('utf-8') after the 
TryRun statement as well.

Thanks
Dave Plater


More information about the Scons-users mailing list