[Scons-users] scons 3.0.1: 'ascii' codec can't decode

Tim Jenness tjenness at lsst.org
Wed Nov 29 10:33:30 EST 2017



> On Nov 29, 2017, at 04:47 , <mpac1234 at will-hier-weg.de> <mpac1234 at will-hier-weg.de> wrote:
> 
> Hi Tim,
> 
> thanks for your reply. As far as I can see get_contents calls get_text_contents
> scons\engine\scons\node\python.py(166)get_csig()
> 165 pass
> --> 166 contents = self.get_contents()
> 167 self.get_ninfo().csig = contents
> 
> scons\engine\scons\node\python.py(143)get_contents()
> 142 def get_contents(self):
> --> 143 text_contents = self.get_text_contents()
> 144 try:
> 
> scons\engine\scons\node\python.py(135)get_text_contents()
> 134 contents = str(self.value)
> --> 135 for kid in self.children(None):
> 136 contents = contents + kid.get_contents().decode()
> 
> Is not the root problem to represent arbitrary data as ASCII? This is how this stuff looks like in SCons 2.5.1:
> --------------
> for kid in self.children(None):
> contents = contents + kid.get_contents()
> return contents
> 
> get_contents = get_text_contents ###TODO should return 'bytes' value
> --------------
> get_contents and get_text_contents are the same. No attempts to decode / encode.
>  
> 

SCons 2.x only worked on python2 and python2 doesn’t care about the distinction between strings and bytes.

In SCons3 get_text_contents() is meant to always return strings and get_contents() is meant to always return bytes. The problem with the line I was referring to is that a bare decode() should never be done without a try block since you don’t really know what encoding those bytes are using.

— 
Tim Jenness


More information about the Scons-users mailing list